{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 线下模型加权融合\n",
    "模拟梯度下降的方法对各个模型进行线性加权融合。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from __future__ import division\n",
    "from __future__ import print_function\n",
    "\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import pickle\n",
    "import os\n",
    "import sys\n",
    "import time \n",
    "sys.path.append('..')\n",
    "from evaluator import score_eval\n",
    "\n",
    "# # 求 softmax\n",
    "def _softmax(score):\n",
    "    \"\"\"对一个样本的输出类别概率进行 softmax 归一化.\n",
    "    score: arr.shape=[1999].\n",
    "    \"\"\"\n",
    "    max_sc = np.max(score)   # 最大分数\n",
    "    score = score - max_sc\n",
    "    exp_sc = np.exp(score)\n",
    "    sum_exp_sc = np.sum(exp_sc)\n",
    "    softmax_sc = exp_sc / sum_exp_sc\n",
    "    return softmax_sc    # 归一化的结果\n",
    "    \n",
    "def softmax(scores):\n",
    "    \"\"\"对所有样本的输出概率进行 softmax 归一化处理。\n",
    "    scores: arr.shape=[n_sample, 1999].\n",
    "    \"\"\"\n",
    "    softmax_scs = map(_softmax, scores)\n",
    "    return np.asarray(softmax_scs)\n",
    "\n",
    "marked_labels_list = np.load('data/marked_labels_list.npy')\n",
    "scores_path = 'local_scores/'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 不同模型的表现能力"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1/37, scores_name= p1-1-bigru-512.npy\n",
      "f1=0.413952\n",
      "2/37, scores_name= p1-2-bigru-512-true.npy\n",
      "f1=0.413378\n",
      "3/37, scores_name= textcnn-fc-drop-title-content-256-3457-drop0.5.npy\n",
      "f1=0.40947\n",
      "4/37, scores_name= f1-1-cnn-256-23457-11.npy\n",
      "f1=0.412223\n",
      "5/37, scores_name= han-cnn-title-content-256-345.npy\n",
      "f1=0.410232\n",
      "6/37, scores_name= han-cnn-title-content-256-23457-1234.npy\n",
      "f1=0.409706\n",
      "7/37, scores_name= m7-rnn-cnn-256-100.npy\n",
      "f1=0.406457\n",
      "8/37, scores_name= p2-1-rnn-cnn-256-256.npy\n",
      "f1=0.410234\n",
      "9/37, scores_name= p3-2-cnn-256-2357.npy\n",
      "f1=0.40933\n",
      "10/37, scores_name= p3-cnn-512-23457.npy\n",
      "f1=0.406415\n",
      "11/37, scores_name= textcnn-fc-drop-title-content-256-345.npy\n",
      "f1=0.408236\n",
      "12/37, scores_name= textcnn-fc-drop-title-content-256-3457-drop0.2.npy\n",
      "f1=0.404698\n",
      "13/37, scores_name= m9-han-bigru-title-content-512-30.npy\n",
      "f1=0.408178\n",
      "14/37, scores_name= m9-2-han-bigru-title-content-512-30.npy\n",
      "f1=0.403398\n",
      "15/37, scores_name= han-bigru-title-content-256-30.npy\n",
      "f1=0.408218\n",
      "16/37, scores_name= m8-han-bigru-256-30.npy\n",
      "f1=0.408106\n",
      "17/37, scores_name= attention-bigru-title-content-256.npy\n",
      "f1=0.396895\n",
      "18/37, scores_name= m7-2-rnn-cnn-128-100.npy\n",
      "f1=0.404153\n",
      "19/37, scores_name= textcnn-fc-title-content-256-345.npy\n",
      "f1=0.397079\n",
      "20/37, scores_name= m1-2-fasttext-topicinfo.npy\n",
      "f1=0.400008\n",
      "21/37, scores_name= ch3-1-cnn-256-2345.npy\n",
      "f1=0.396852\n",
      "22/37, scores_name= ch3-2-cnn-256-23457.npy\n",
      "f1=0.397764\n",
      "23/37, scores_name= ch4-1-han-bigru-256-52.npy\n",
      "f1=0.397745\n",
      "24/37, scores_name= ch5-1-2embed-rnn256-cnn2345.npy\n",
      "f1=0.399414\n",
      "25/37, scores_name= p4-1-han-bigru-256.npy\n",
      "f1=0.407782\n",
      "26/37, scores_name= ch6-1-han-cnn-2345-1234.npy\n",
      "f1=0.397567\n",
      "27/37, scores_name= p5-1-2embed-rnn256-cnn2345.npy\n",
      "f1=0.406252\n",
      "28/37, scores_name= ch5-2-2embed-rnn512-cnn3457.npy\n",
      "f1=0.398458\n",
      "29/37, scores_name= c1-1-cnn-max-256-23457.npy\n",
      "f1=0.413798\n",
      "30/37, scores_name= c1-2-cnn-256-345710.npy\n",
      "f1=0.410514\n",
      "31/37, scores_name= c2-1-bigru-256.npy\n",
      "f1=0.405121\n",
      "32/37, scores_name= textcnn-fc-drop-title-content-256-345-cross3cross0.npy\n",
      "f1=0.402116\n",
      "33/37, scores_name= textcnn-fc-drop-title-content-256-345-cross3cross1.npy\n",
      "f1=0.40203\n",
      "34/37, scores_name= textcnn-fc-drop-title-content-256-345-cross3cross2.npy\n",
      "f1=0.402018\n",
      "35/37, scores_name= p3-3-cnn-max-256-345710.npy\n",
      "f1=0.409939\n",
      "36/37, scores_name= textcnn-title-256-len50.npy\n",
      "f1=0.389508\n",
      "37/37, scores_name= ch7-1-2embed-rnn256-hcnn-2345-1234.npy\n",
      "f1=0.393531\n"
     ]
    }
   ],
   "source": [
    "time0 = time.time()\n",
    "scores_names =[\n",
    "    'p1-1-bigru-512.npy',\n",
    "    'p1-2-bigru-512-true.npy',\n",
    "    'textcnn-fc-drop-title-content-256-3457-drop0.5.npy',\n",
    "    'f1-1-cnn-256-23457-11.npy',\n",
    "\n",
    "    'han-cnn-title-content-256-345.npy',\n",
    "    'han-cnn-title-content-256-23457-1234.npy',\n",
    "    'm7-rnn-cnn-256-100.npy',\n",
    "    'p2-1-rnn-cnn-256-256.npy',\n",
    "\n",
    "    'p3-2-cnn-256-2357.npy',\n",
    "    'p3-cnn-512-23457.npy',\n",
    "    'textcnn-fc-drop-title-content-256-345.npy',   # 提高了两个千分点\n",
    "    'textcnn-fc-drop-title-content-256-3457-drop0.2.npy',\n",
    "\n",
    "    'm9-han-bigru-title-content-512-30.npy',\n",
    "    'm9-2-han-bigru-title-content-512-30.npy',\n",
    "    'han-bigru-title-content-256-30.npy',\n",
    "    'm8-han-bigru-256-30.npy',\n",
    "\n",
    "    'attention-bigru-title-content-256.npy',\n",
    "    'm7-2-rnn-cnn-128-100.npy',\n",
    "    'textcnn-fc-title-content-256-345.npy',\n",
    "    'm1-2-fasttext-topicinfo.npy',\n",
    "\n",
    "    'ch3-1-cnn-256-2345.npy',\n",
    "    'ch3-2-cnn-256-23457.npy', \n",
    "    'ch4-1-han-bigru-256-52.npy',    \n",
    "    'ch5-1-2embed-rnn256-cnn2345.npy',\n",
    "\n",
    "    'p4-1-han-bigru-256.npy',\n",
    "    'ch6-1-han-cnn-2345-1234.npy',\n",
    "    'p5-1-2embed-rnn256-cnn2345.npy',\n",
    "    'ch5-2-2embed-rnn512-cnn3457.npy',\n",
    "\n",
    "    'c1-1-cnn-max-256-23457.npy',\n",
    "    'c1-2-cnn-256-345710.npy',     \n",
    "    'c2-1-bigru-256.npy',\n",
    "    \n",
    "    'textcnn-fc-drop-title-content-256-345-cross3cross0.npy',\n",
    "    'textcnn-fc-drop-title-content-256-345-cross3cross1.npy',\n",
    "    'textcnn-fc-drop-title-content-256-345-cross3cross2.npy',\n",
    "    'p3-3-cnn-max-256-345710.npy',\n",
    "    'textcnn-title-256-len50.npy',\n",
    "    'ch7-1-2embed-rnn256-hcnn-2345-1234.npy',\n",
    "]  \n",
    "   \n",
    "\n",
    "soft_scores_path = 'local_scores/'\n",
    "scores_name_num = len(scores_names)\n",
    "f1s = list()\n",
    "for i in xrange(scores_name_num):\n",
    "    scores_name = scores_names[i]\n",
    "    print('%d/%d, scores_name= %s' % (i+1, scores_name_num, scores_name))\n",
    "    score = np.vstack(np.load(soft_scores_path + scores_name))\n",
    "    score = softmax(score)\n",
    "    predict_labels_list = map(lambda label: label.argsort()[-1:-6:-1], score) # 取最大的5个下标\n",
    "    predict_label_and_marked_label_list = zip(predict_labels_list, marked_labels_list)\n",
    "    precision, recall, f1 = score_eval(predict_label_and_marked_label_list)\n",
    "    print('f1=%g' % f1)\n",
    "    f1s.append(f1)\n",
    "    \n",
    "weights = [  9.75938817,   8.63945014,  2.98289344,   3.72323394,   5.04378259,\n",
    "   0.06551187,  -0.79412528,  -0.21665029,   4.90162676,   1.17452791,\n",
    "  -1.46124679,  -0.25384273,   5.50925013,   2.84186738,  -0.93016907,\n",
    "   5.16519035,  -0.47061662,   2.75998217,   2.58152296,  -1.24553333,\n",
    "   2.43288558,   6.17376317,   5.59323762,  10.46123521,   5.29952925,\n",
    "   3.72042086,   5.46707444,   5.51516916,   5.82352659,   1.27847427,\n",
    "  -0.52930247,  -1.99052155,  -3.0938045,   -2.07007845,   4.19963813,\n",
    "   2.10593832,   1.74174258]\n",
    "    \n",
    "df_result = pd.DataFrame({'model_name': scores_names, 'f1': f1s, 'weight': weights})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>model_name</th>\n",
       "      <th>f1</th>\n",
       "      <th>weight</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>ch5-1-2embed-rnn256-cnn2345.npy</td>\n",
       "      <td>0.399414</td>\n",
       "      <td>10.461235</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>p1-1-bigru-512.npy</td>\n",
       "      <td>0.413952</td>\n",
       "      <td>9.759388</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>p1-2-bigru-512-true.npy</td>\n",
       "      <td>0.413378</td>\n",
       "      <td>8.639450</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>ch3-2-cnn-256-23457.npy</td>\n",
       "      <td>0.397764</td>\n",
       "      <td>6.173763</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>c1-1-cnn-max-256-23457.npy</td>\n",
       "      <td>0.413798</td>\n",
       "      <td>5.823527</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>ch4-1-han-bigru-256-52.npy</td>\n",
       "      <td>0.397745</td>\n",
       "      <td>5.593238</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>ch5-2-2embed-rnn512-cnn3457.npy</td>\n",
       "      <td>0.398458</td>\n",
       "      <td>5.515169</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>m9-han-bigru-title-content-512-30.npy</td>\n",
       "      <td>0.408178</td>\n",
       "      <td>5.509250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>p5-1-2embed-rnn256-cnn2345.npy</td>\n",
       "      <td>0.406252</td>\n",
       "      <td>5.467074</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>p4-1-han-bigru-256.npy</td>\n",
       "      <td>0.407782</td>\n",
       "      <td>5.299529</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>m8-han-bigru-256-30.npy</td>\n",
       "      <td>0.408106</td>\n",
       "      <td>5.165190</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>han-cnn-title-content-256-345.npy</td>\n",
       "      <td>0.410232</td>\n",
       "      <td>5.043783</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>p3-2-cnn-256-2357.npy</td>\n",
       "      <td>0.409330</td>\n",
       "      <td>4.901627</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>p3-3-cnn-max-256-345710.npy</td>\n",
       "      <td>0.409939</td>\n",
       "      <td>4.199638</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>f1-1-cnn-256-23457-11.npy</td>\n",
       "      <td>0.412223</td>\n",
       "      <td>3.723234</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>ch6-1-han-cnn-2345-1234.npy</td>\n",
       "      <td>0.397567</td>\n",
       "      <td>3.720421</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>textcnn-fc-drop-title-content-256-3457-drop0.5...</td>\n",
       "      <td>0.409470</td>\n",
       "      <td>2.982893</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>m9-2-han-bigru-title-content-512-30.npy</td>\n",
       "      <td>0.403398</td>\n",
       "      <td>2.841867</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>m7-2-rnn-cnn-128-100.npy</td>\n",
       "      <td>0.404153</td>\n",
       "      <td>2.759982</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>textcnn-fc-title-content-256-345.npy</td>\n",
       "      <td>0.397079</td>\n",
       "      <td>2.581523</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>ch3-1-cnn-256-2345.npy</td>\n",
       "      <td>0.396852</td>\n",
       "      <td>2.432886</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>textcnn-title-256-len50.npy</td>\n",
       "      <td>0.389508</td>\n",
       "      <td>2.105938</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>ch7-1-2embed-rnn256-hcnn-2345-1234.npy</td>\n",
       "      <td>0.393531</td>\n",
       "      <td>1.741743</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>c1-2-cnn-256-345710.npy</td>\n",
       "      <td>0.410514</td>\n",
       "      <td>1.278474</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>p3-cnn-512-23457.npy</td>\n",
       "      <td>0.406415</td>\n",
       "      <td>1.174528</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>han-cnn-title-content-256-23457-1234.npy</td>\n",
       "      <td>0.409706</td>\n",
       "      <td>0.065512</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>p2-1-rnn-cnn-256-256.npy</td>\n",
       "      <td>0.410234</td>\n",
       "      <td>-0.216650</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>textcnn-fc-drop-title-content-256-3457-drop0.2...</td>\n",
       "      <td>0.404698</td>\n",
       "      <td>-0.253843</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>attention-bigru-title-content-256.npy</td>\n",
       "      <td>0.396895</td>\n",
       "      <td>-0.470617</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>c2-1-bigru-256.npy</td>\n",
       "      <td>0.405121</td>\n",
       "      <td>-0.529302</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>m7-rnn-cnn-256-100.npy</td>\n",
       "      <td>0.406457</td>\n",
       "      <td>-0.794125</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>han-bigru-title-content-256-30.npy</td>\n",
       "      <td>0.408218</td>\n",
       "      <td>-0.930169</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>m1-2-fasttext-topicinfo.npy</td>\n",
       "      <td>0.400008</td>\n",
       "      <td>-1.245533</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>textcnn-fc-drop-title-content-256-345.npy</td>\n",
       "      <td>0.408236</td>\n",
       "      <td>-1.461247</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>textcnn-fc-drop-title-content-256-345-cross3cr...</td>\n",
       "      <td>0.402116</td>\n",
       "      <td>-1.990522</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>textcnn-fc-drop-title-content-256-345-cross3cr...</td>\n",
       "      <td>0.402018</td>\n",
       "      <td>-2.070078</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>textcnn-fc-drop-title-content-256-345-cross3cr...</td>\n",
       "      <td>0.402030</td>\n",
       "      <td>-3.093805</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                           model_name        f1     weight\n",
       "23                    ch5-1-2embed-rnn256-cnn2345.npy  0.399414  10.461235\n",
       "0                                  p1-1-bigru-512.npy  0.413952   9.759388\n",
       "1                             p1-2-bigru-512-true.npy  0.413378   8.639450\n",
       "21                            ch3-2-cnn-256-23457.npy  0.397764   6.173763\n",
       "28                         c1-1-cnn-max-256-23457.npy  0.413798   5.823527\n",
       "22                         ch4-1-han-bigru-256-52.npy  0.397745   5.593238\n",
       "27                    ch5-2-2embed-rnn512-cnn3457.npy  0.398458   5.515169\n",
       "12              m9-han-bigru-title-content-512-30.npy  0.408178   5.509250\n",
       "26                     p5-1-2embed-rnn256-cnn2345.npy  0.406252   5.467074\n",
       "24                             p4-1-han-bigru-256.npy  0.407782   5.299529\n",
       "15                            m8-han-bigru-256-30.npy  0.408106   5.165190\n",
       "4                   han-cnn-title-content-256-345.npy  0.410232   5.043783\n",
       "8                               p3-2-cnn-256-2357.npy  0.409330   4.901627\n",
       "34                        p3-3-cnn-max-256-345710.npy  0.409939   4.199638\n",
       "3                           f1-1-cnn-256-23457-11.npy  0.412223   3.723234\n",
       "25                        ch6-1-han-cnn-2345-1234.npy  0.397567   3.720421\n",
       "2   textcnn-fc-drop-title-content-256-3457-drop0.5...  0.409470   2.982893\n",
       "13            m9-2-han-bigru-title-content-512-30.npy  0.403398   2.841867\n",
       "17                           m7-2-rnn-cnn-128-100.npy  0.404153   2.759982\n",
       "18               textcnn-fc-title-content-256-345.npy  0.397079   2.581523\n",
       "20                             ch3-1-cnn-256-2345.npy  0.396852   2.432886\n",
       "35                        textcnn-title-256-len50.npy  0.389508   2.105938\n",
       "36             ch7-1-2embed-rnn256-hcnn-2345-1234.npy  0.393531   1.741743\n",
       "29                            c1-2-cnn-256-345710.npy  0.410514   1.278474\n",
       "9                                p3-cnn-512-23457.npy  0.406415   1.174528\n",
       "5            han-cnn-title-content-256-23457-1234.npy  0.409706   0.065512\n",
       "7                            p2-1-rnn-cnn-256-256.npy  0.410234  -0.216650\n",
       "11  textcnn-fc-drop-title-content-256-3457-drop0.2...  0.404698  -0.253843\n",
       "16              attention-bigru-title-content-256.npy  0.396895  -0.470617\n",
       "30                                 c2-1-bigru-256.npy  0.405121  -0.529302\n",
       "6                              m7-rnn-cnn-256-100.npy  0.406457  -0.794125\n",
       "14                 han-bigru-title-content-256-30.npy  0.408218  -0.930169\n",
       "19                        m1-2-fasttext-topicinfo.npy  0.400008  -1.245533\n",
       "10          textcnn-fc-drop-title-content-256-345.npy  0.408236  -1.461247\n",
       "31  textcnn-fc-drop-title-content-256-345-cross3cr...  0.402116  -1.990522\n",
       "33  textcnn-fc-drop-title-content-256-345-cross3cr...  0.402018  -2.070078\n",
       "32  textcnn-fc-drop-title-content-256-345-cross3cr...  0.402030  -3.093805"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_result = df_result.loc[:, ['model_name', 'f1', 'weight']]\n",
    "df_result = df_result.sort_values('weight', ascending=False)\n",
    "df_result.to_csv('model_f1.csv', index=False)\n",
    "df_result"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "### 手动初始化\n",
    "初始化根据单模型的表现能力赋值，也可以通过直接平均加权来探索单模型对于整体的提高贡献来赋值。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "37 37\n",
      "All 37 models\n",
      "1/37, scores_name= p1-1-bigru-512.npy\n",
      "2/37, scores_name= p1-2-bigru-512-true.npy\n",
      "3/37, scores_name= textcnn-fc-drop-title-content-256-3457-drop0.5.npy\n",
      "4/37, scores_name= f1-1-cnn-256-23457-11.npy\n",
      "5/37, scores_name= han-cnn-title-content-256-345.npy\n",
      "6/37, scores_name= han-cnn-title-content-256-23457-1234.npy\n",
      "7/37, scores_name= m7-rnn-cnn-256-100.npy\n",
      "8/37, scores_name= p2-1-rnn-cnn-256-256.npy\n",
      "9/37, scores_name= p3-2-cnn-256-2357.npy\n",
      "10/37, scores_name= p3-cnn-512-23457.npy\n",
      "11/37, scores_name= textcnn-fc-drop-title-content-256-345.npy\n",
      "12/37, scores_name= textcnn-fc-drop-title-content-256-3457-drop0.2.npy\n",
      "13/37, scores_name= m9-han-bigru-title-content-512-30.npy\n",
      "14/37, scores_name= m9-2-han-bigru-title-content-512-30.npy\n",
      "15/37, scores_name= han-bigru-title-content-256-30.npy\n",
      "16/37, scores_name= m8-han-bigru-256-30.npy\n",
      "17/37, scores_name= attention-bigru-title-content-256.npy\n",
      "18/37, scores_name= m7-2-rnn-cnn-128-100.npy\n",
      "19/37, scores_name= textcnn-fc-title-content-256-345.npy\n",
      "20/37, scores_name= m1-2-fasttext-topicinfo.npy\n",
      "21/37, scores_name= ch3-1-cnn-256-2345.npy\n",
      "22/37, scores_name= ch3-2-cnn-256-23457.npy\n",
      "23/37, scores_name= ch4-1-han-bigru-256-52.npy\n",
      "24/37, scores_name= ch5-1-2embed-rnn256-cnn2345.npy\n",
      "25/37, scores_name= p4-1-han-bigru-256.npy\n",
      "26/37, scores_name= ch6-1-han-cnn-2345-1234.npy\n",
      "27/37, scores_name= p5-1-2embed-rnn256-cnn2345.npy\n",
      "28/37, scores_name= ch5-2-2embed-rnn512-cnn3457.npy\n",
      "29/37, scores_name= c1-1-cnn-max-256-23457.npy\n",
      "30/37, scores_name= c1-2-cnn-256-345710.npy\n",
      "31/37, scores_name= c2-1-bigru-256.npy\n",
      "32/37, scores_name= textcnn-fc-drop-title-content-256-345-cross3cross0.npy\n",
      "33/37, scores_name= textcnn-fc-drop-title-content-256-345-cross3cross1.npy\n",
      "34/37, scores_name= textcnn-fc-drop-title-content-256-345-cross3cross2.npy\n",
      "35/37, scores_name= p3-3-cnn-max-256-345710.npy\n",
      "36/37, scores_name= textcnn-title-256-len50.npy\n",
      "37/37, scores_name= ch7-1-2embed-rnn256-hcnn-2345-1234.npy\n",
      "sum_scores.shape= (100000, 1999)\n",
      "local valid p=1.48635, r=0.60698, f1=0.430981;\n",
      "Finished , costed time 324.45 s\n"
     ]
    }
   ],
   "source": [
    "time0 = time.time()\n",
    "scores_names =[\n",
    "    'p1-1-bigru-512.npy',\n",
    "    'p1-2-bigru-512-true.npy',\n",
    "    'textcnn-fc-drop-title-content-256-3457-drop0.5.npy',\n",
    "    'f1-1-cnn-256-23457-11.npy',\n",
    "\n",
    "    'han-cnn-title-content-256-345.npy',\n",
    "    'han-cnn-title-content-256-23457-1234.npy',\n",
    "    'm7-rnn-cnn-256-100.npy',\n",
    "    'p2-1-rnn-cnn-256-256.npy',\n",
    "\n",
    "    'p3-2-cnn-256-2357.npy',\n",
    "    'p3-cnn-512-23457.npy',\n",
    "    'textcnn-fc-drop-title-content-256-345.npy',   # 提高了两个千分点\n",
    "    'textcnn-fc-drop-title-content-256-3457-drop0.2.npy',\n",
    "\n",
    "    'm9-han-bigru-title-content-512-30.npy',\n",
    "    'm9-2-han-bigru-title-content-512-30.npy',\n",
    "    'han-bigru-title-content-256-30.npy',\n",
    "    'm8-han-bigru-256-30.npy',\n",
    "\n",
    "    'attention-bigru-title-content-256.npy',\n",
    "    'm7-2-rnn-cnn-128-100.npy',\n",
    "    'textcnn-fc-title-content-256-345.npy',\n",
    "    'm1-2-fasttext-topicinfo.npy',\n",
    "\n",
    "    'ch3-1-cnn-256-2345.npy',\n",
    "    'ch3-2-cnn-256-23457.npy', \n",
    "    'ch4-1-han-bigru-256-52.npy',    \n",
    "    'ch5-1-2embed-rnn256-cnn2345.npy',\n",
    "\n",
    "    'p4-1-han-bigru-256.npy',\n",
    "    'ch6-1-han-cnn-2345-1234.npy',\n",
    "    'p5-1-2embed-rnn256-cnn2345.npy',\n",
    "    'ch5-2-2embed-rnn512-cnn3457.npy',\n",
    "\n",
    "    'c1-1-cnn-max-256-23457.npy',\n",
    "    'c1-2-cnn-256-345710.npy',     \n",
    "    'c2-1-bigru-256.npy',\n",
    "    \n",
    "    'textcnn-fc-drop-title-content-256-345-cross3cross0.npy',\n",
    "    'textcnn-fc-drop-title-content-256-345-cross3cross1.npy',\n",
    "    'textcnn-fc-drop-title-content-256-345-cross3cross2.npy',\n",
    "    'p3-3-cnn-max-256-345710.npy',\n",
    "    'textcnn-title-256-len50.npy',\n",
    "    'ch7-1-2embed-rnn256-hcnn-2345-1234.npy',\n",
    "]  \n",
    "   \n",
    "\n",
    "weights = [  9.75938817,   8.63945014,  2.98289344,   3.72323394,   5.04378259,\n",
    "   0.06551187,  -0.79412528,  -0.21665029,   4.90162676,   1.17452791,\n",
    "  -1.46124679,  -0.25384273,   5.50925013,   2.84186738,  -0.93016907,\n",
    "   5.16519035,  -0.47061662,   2.75998217,   2.58152296,  -1.24553333,\n",
    "   2.43288558,   6.17376317,   5.59323762,  10.46123521,   5.29952925,\n",
    "   3.72042086,   5.46707444,   5.51516916,   5.82352659,   1.27847427,\n",
    "  -0.52930247,  -1.99052155,  -3.0938045,   -2.07007845,   4.19963813,\n",
    "   2.10593832,   1.74174258]\n",
    "\n",
    "soft_scores_path = 'local_scores/'\n",
    "print(len(scores_names), len(weights))\n",
    "print('All %d models' % len(weights))\n",
    "sum_scores = np.zeros((len(marked_labels_list), 1999), dtype=float)\n",
    "scores_name_num = len(scores_names)\n",
    "for i in xrange(len(weights)):\n",
    "    scores_name = scores_names[i]\n",
    "    print('%d/%d, scores_name= %s' % (i+1, scores_name_num, scores_name))\n",
    "    score = np.vstack(np.load(soft_scores_path + scores_name))\n",
    "    score = softmax(score)\n",
    "    sum_scores = sum_scores + score* weights[i]\n",
    "print('sum_scores.shape=',sum_scores.shape)\n",
    "predict_labels_list = map(lambda label: label.argsort()[-1:-6:-1], sum_scores) # 取最大的5个下标\n",
    "predict_label_and_marked_label_list = zip(predict_labels_list, marked_labels_list)\n",
    "precision, recall, f1 = score_eval(predict_label_and_marked_label_list)\n",
    "print('local valid p=%g, r=%g, f1=%g;' % ( precision, recall, f1))\n",
    "print('Finished , costed time %g s' % (time.time() - time0))\n",
    "last_f1 = f1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 模拟梯度下降方式进行权重调整\n",
    "- 在初期可以把学习率设置大些，比如 0.5;\n",
    "- 后期可能权重基本不能变动或者线下的 f1 值变动不大，这时候需要手动调整一下权重，比如把权值千分位及后面的小数点全部去掉，加入扰动以后 f1 值继续取得一定的提高。\n",
    "- 迭代到一定程度会对线下数据集过拟合，所以需要线上评测来验证最后的结果。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "==================== 0 0.14925\n",
      "LAST_F1= 0.431113164863\n",
      "update_w= [ 0.14925  0.       0.      -0.14925 -0.14925  0.      -0.14925  0.\n",
      "  0.14925  0.       0.       0.       0.       0.       0.       0.       0.\n",
      "  0.       0.       0.      -0.14925  0.       0.      -0.14925  0.       0.\n",
      "  0.       0.       0.       0.       0.       0.       0.       0.       0.\n",
      "  0.14925  0.     ]\n",
      "new_w= [ 13.21925  12.3       3.3       6.27075   7.40075  -1.03      0.62075\n",
      "   0.13      5.99925   4.12     -1.62      1.31      7.58      2.98     -0.61\n",
      "   5.75      1.24      4.85      4.57      0.37      3.18075   9.82      8.26\n",
      "  14.24075   7.57      6.33      8.29      8.9       9.79      2.69      0.29\n",
      "  -0.58     -5.12     -2.13      5.14      3.40925   3.88   ]\n",
      "NEW_F1= 0.431089025211\n",
      "**Best_f1=0.431113; Speed: 336.325 s / epoch.\n",
      "==================== 1 0.14850375\n",
      "LAST_F1= 0.431089025211\n",
      "update_w= [-0.14850375  0.14850375 -0.14850375  0.          0.14850375 -0.14850375\n",
      "  0.14850375 -0.14850375 -0.14850375 -0.14850375  0.14850375 -0.14850375\n",
      "  0.14850375 -0.14850375  0.          0.14850375 -0.14850375 -0.14850375\n",
      " -0.14850375 -0.14850375  0.14850375  0.14850375 -0.14850375  0.14850375\n",
      "  0.          0.         -0.14850375  0.          0.14850375  0.\n",
      "  0.14850375 -0.14850375  0.          0.          0.          0.14850375\n",
      "  0.        ]\n",
      "new_w= [ 13.07074625  12.44850375   3.15149625   6.27075      7.54925375\n",
      "  -1.17850375   0.76925375  -0.01850375   5.85074625   3.97149625\n",
      "  -1.47149625   1.16149625   7.72850375   2.83149625  -0.61         5.89850375\n",
      "   1.09149625   4.70149625   4.42149625   0.22149625   3.32925375\n",
      "   9.96850375   8.11149625  14.38925375   7.57         6.33         8.14149625\n",
      "   8.9          9.93850375   2.69         0.43850375  -0.72850375  -5.12\n",
      "  -2.13         5.14         3.55775375   3.88      ]\n",
      "NEW_F1= 0.431067631547\n",
      "**Best_f1=0.431113; Speed: 380.071 s / epoch.\n",
      "==================== 2 0.14776123125\n",
      "LAST_F1= 0.431067631547\n",
      "update_w= [ 0.14776123  0.14776123  0.14776123  0.          0.          0.14776123\n",
      "  0.          0.          0.14776123  0.14776123 -0.14776123  0.14776123\n",
      " -0.14776123  0.          0.         -0.14776123  0.14776123  0.14776123\n",
      "  0.14776123 -0.14776123 -0.14776123 -0.14776123  0.         -0.14776123\n",
      "  0.14776123  0.          0.14776123  0.         -0.14776123 -0.14776123\n",
      " -0.14776123 -0.14776123 -0.14776123  0.          0.14776123  0.\n",
      " -0.14776123]\n",
      "new_w= [ 13.21850748  12.59626498   3.29925748   6.27075      7.54925375\n",
      "  -1.03074252   0.76925375  -0.01850375   5.99850748   4.11925748\n",
      "  -1.61925748   1.30925748   7.58074252   2.83149625  -0.61         5.75074252\n",
      "   1.23925748   4.84925748   4.56925748   0.07373502   3.18149252\n",
      "   9.82074252   8.11149625  14.24149252   7.71776123   6.33         8.28925748\n",
      "   8.9          9.79074252   2.54223877   0.29074252  -0.87626498\n",
      "  -5.26776123  -2.13         5.28776123   3.55775375   3.73223877]\n",
      "NEW_F1= 0.431082764175\n",
      "**Best_f1=0.431113; Speed: 366.918 s / epoch.\n",
      "==================== 3 0.147022425094\n",
      "LAST_F1= 0.431082764175\n",
      "update_w= [-0.14702243 -0.14702243  0.14702243 -0.14702243  0.         -0.14702243\n",
      "  0.         -0.14702243 -0.14702243 -0.14702243  0.14702243  0.14702243\n",
      " -0.14702243  0.14702243  0.14702243  0.14702243  0.14702243 -0.14702243\n",
      "  0.14702243  0.          0.14702243  0.14702243  0.14702243  0.14702243\n",
      "  0.         -0.14702243  0.14702243  0.14702243  0.14702243  0.14702243\n",
      " -0.14702243  0.14702243  0.14702243  0.14702243 -0.14702243  0.14702243\n",
      "  0.14702243]\n",
      "new_w= [ 13.07148506  12.44924256   3.44627991   6.12372757   7.54925375\n",
      "  -1.17776494   0.76925375  -0.16552618   5.85148506   3.97223506\n",
      "  -1.47223506   1.45627991   7.43372009   2.97851868  -0.46297757\n",
      "   5.89776494   1.38627991   4.70223506   4.71627991   0.07373502\n",
      "   3.32851494   9.96776494   8.25851868  14.38851494   7.71776123\n",
      "   6.18297757   8.43627991   9.04702243   9.93776494   2.68926119\n",
      "   0.14372009  -0.72924256  -5.12073881  -1.98297757   5.14073881\n",
      "   3.70477618   3.87926119]\n",
      "NEW_F1= 0.431036077564\n",
      "**Best_f1=0.431113; Speed: 361.987 s / epoch.\n",
      "==================== 4 0.146287312968\n",
      "LAST_F1= 0.431036077564\n",
      "update_w= [ 0.14628731  0.          0.14628731  0.14628731  0.          0.\n",
      "  0.14628731  0.          0.          0.14628731 -0.14628731 -0.14628731\n",
      "  0.          0.14628731 -0.14628731  0.14628731  0.          0.14628731\n",
      "  0.         -0.14628731  0.          0.          0.          0.\n",
      " -0.14628731  0.14628731  0.          0.         -0.14628731 -0.14628731\n",
      "  0.          0.         -0.14628731  0.          0.         -0.14628731\n",
      "  0.14628731]\n",
      "new_w= [ 13.21777237  12.44924256   3.59256722   6.27001489   7.54925375\n",
      "  -1.17776494   0.91554106  -0.16552618   5.85148506   4.11852237\n",
      "  -1.61852237   1.30999259   7.43372009   3.12480599  -0.60926489\n",
      "   6.04405226   1.38627991   4.84852237   4.71627991  -0.07255229\n",
      "   3.32851494   9.96776494   8.25851868  14.38851494   7.57147392\n",
      "   6.32926489   8.43627991   9.04702243   9.79147763   2.54297388\n",
      "   0.14372009  -0.72924256  -5.26702612  -1.98297757   5.14073881\n",
      "   3.55848886   4.02554851]\n",
      "NEW_F1= 0.431079182921\n",
      "**Best_f1=0.431113; Speed: 370.276 s / epoch.\n",
      "==================== 5 0.145555876403\n",
      "LAST_F1= 0.431079182921\n",
      "update_w= [ 0.14555588  0.14555588  0.14555588  0.          0.14555588  0.          0.\n",
      "  0.          0.14555588  0.14555588  0.          0.          0.14555588\n",
      " -0.14555588 -0.14555588  0.14555588  0.          0.          0.\n",
      "  0.14555588  0.         -0.14555588 -0.14555588 -0.14555588  0.14555588\n",
      "  0.          0.14555588  0.          0.14555588  0.14555588  0.          0.\n",
      "  0.          0.          0.14555588  0.14555588 -0.14555588]\n",
      "new_w= [ 13.36332825  12.59479843   3.7381231    6.27001489   7.69480963\n",
      "  -1.17776494   0.91554106  -0.16552618   5.99704093   4.26407825\n",
      "  -1.61852237   1.30999259   7.57927597   2.97925011  -0.75482076\n",
      "   6.18960813   1.38627991   4.84852237   4.71627991   0.07300358\n",
      "   3.32851494   9.82220907   8.1129628   14.24295907   7.71702979\n",
      "   6.32926489   8.58183578   9.04702243   9.93703351   2.68852976\n",
      "   0.14372009  -0.72924256  -5.26702612  -1.98297757   5.28629468\n",
      "   3.70404474   3.87999263]\n",
      "NEW_F1= 0.431032804509\n",
      "**Best_f1=0.431113; Speed: 353.755 s / epoch.\n",
      "==================== 6 0.144828097021\n",
      "LAST_F1= 0.431032804509\n",
      "update_w= [ 0.1448281 -0.1448281 -0.1448281 -0.1448281  0.1448281  0.1448281\n",
      " -0.1448281 -0.1448281 -0.1448281  0.1448281  0.         0.1448281\n",
      "  0.1448281 -0.1448281 -0.1448281 -0.1448281 -0.1448281  0.1448281\n",
      "  0.1448281  0.1448281  0.1448281  0.1448281  0.1448281  0.1448281\n",
      "  0.1448281  0.1448281 -0.1448281  0.1448281  0.1448281 -0.1448281\n",
      " -0.1448281  0.1448281  0.1448281  0.1448281  0.1448281 -0.1448281\n",
      "  0.1448281]\n",
      "new_w= [  1.35081563e+01   1.24499703e+01   3.59329500e+00   6.12518679e+00\n",
      "   7.83963772e+00  -1.03293685e+00   7.70712966e-01  -3.10354272e-01\n",
      "   5.85221284e+00   4.40890634e+00  -1.61852237e+00   1.45482069e+00\n",
      "   7.72410407e+00   2.83442201e+00  -8.99648861e-01   6.04478004e+00\n",
      "   1.24145181e+00   4.99335047e+00   4.86110800e+00   2.17831679e-01\n",
      "   3.47334304e+00   9.96703716e+00   8.25779090e+00   1.43877872e+01\n",
      "   7.86185789e+00   6.47409298e+00   8.43700769e+00   9.19185052e+00\n",
      "   1.00818616e+01   2.54370166e+00  -1.10800337e-03  -5.84414459e-01\n",
      "  -5.12219802e+00  -1.83814948e+00   5.43112278e+00   3.55921664e+00\n",
      "   4.02482073e+00]\n",
      "NEW_F1= 0.431056681947\n",
      "**Best_f1=0.431113; Speed: 336.602 s / epoch.\n",
      "==================== 7 0.144103956536\n",
      "LAST_F1= 0.431056681947\n",
      "update_w= [ 0.14410396  0.14410396  0.          0.14410396  0.14410396  0.\n",
      "  0.14410396  0.          0.14410396  0.14410396 -0.14410396  0.14410396\n",
      "  0.          0.14410396  0.14410396 -0.14410396  0.14410396  0.14410396\n",
      " -0.14410396  0.          0.          0.          0.         -0.14410396\n",
      "  0.14410396  0.14410396  0.         -0.14410396  0.14410396  0.14410396\n",
      "  0.14410396  0.         -0.14410396  0.          0.          0.          0.        ]\n",
      "new_w= [ 13.6522603   12.59407429   3.593295     6.26929075   7.98374168\n",
      "  -1.03293685   0.91481692  -0.31035427   5.99631679   4.5530103\n",
      "  -1.76262633   1.59892465   7.72410407   2.97852597  -0.7555449\n",
      "   5.90067608   1.38555577   5.13745442   4.71700405   0.21783168\n",
      "   3.47334304   9.96703716   8.2577909   14.24368321   8.00596185\n",
      "   6.61819694   8.43700769   9.04774657  10.22596556   2.68780562\n",
      "   0.14299595  -0.58441446  -5.26630198  -1.83814948   5.43112278\n",
      "   3.55921664   4.02482073]\n",
      "NEW_F1= 0.431082949346\n",
      "**Best_f1=0.431113; Speed: 340.436 s / epoch.\n",
      "==================== 8 0.143383436754\n",
      "LAST_F1= 0.431082949346\n",
      "update_w= [ 0.          0.         -0.14338344 -0.14338344  0.          0.\n",
      "  0.14338344  0.          0.          0.          0.          0.\n",
      " -0.14338344  0.          0.          0.          0.          0.          0.\n",
      "  0.          0.          0.          0.          0.          0.          0.\n",
      "  0.          0.14338344  0.         -0.14338344  0.          0.\n",
      " -0.14338344 -0.14338344  0.          0.          0.        ]\n",
      "new_w= [ 13.6522603   12.59407429   3.44991156   6.12590731   7.98374168\n",
      "  -1.03293685   1.05820036  -0.31035427   5.99631679   4.5530103\n",
      "  -1.76262633   1.59892465   7.58072063   2.97852597  -0.7555449\n",
      "   5.90067608   1.38555577   5.13745442   4.71700405   0.21783168\n",
      "   3.47334304   9.96703716   8.2577909   14.24368321   8.00596185\n",
      "   6.61819694   8.43700769   9.19113     10.22596556   2.54442218\n",
      "   0.14299595  -0.58441446  -5.40968542  -1.98153291   5.43112278\n",
      "   3.55921664   4.02482073]\n",
      "NEW_F1= 0.431082574434\n",
      "**Best_f1=0.431113; Speed: 375.87 s / epoch.\n",
      "==================== 9 0.14266651957\n",
      "LAST_F1= 0.431082574434\n",
      "update_w= [ 0.14266652 -0.14266652 -0.14266652 -0.14266652 -0.14266652  0.14266652\n",
      " -0.14266652 -0.14266652  0.14266652 -0.14266652  0.14266652 -0.14266652\n",
      " -0.14266652 -0.14266652  0.14266652  0.14266652 -0.14266652 -0.14266652\n",
      " -0.14266652  0.14266652  0.14266652  0.         -0.14266652  0.14266652\n",
      "  0.14266652  0.14266652  0.14266652  0.14266652  0.          0.14266652\n",
      "  0.14266652 -0.14266652 -0.14266652  0.14266652  0.14266652  0.14266652\n",
      " -0.14266652]\n",
      "new_w= [ 13.79492682  12.45140777   3.30724504   5.98324079   7.84107516\n",
      "  -0.89027033   0.91553384  -0.45302079   6.13898331   4.41034378\n",
      "  -1.61995981   1.45625813   7.43805411   2.83585945  -0.61287839\n",
      "   6.0433426    1.24288925   4.9947879    4.57433753   0.3604982\n",
      "   3.61600956   9.96703716   8.11512438  14.38634973   8.14862837\n",
      "   6.76086346   8.57967421   9.33379652  10.22596556   2.6870887\n",
      "   0.28566247  -0.72708098  -5.55235193  -1.8388664    5.5737893\n",
      "   3.70188316   3.88215421]\n",
      "NEW_F1= 0.431080450406\n",
      "**Best_f1=0.431113; Speed: 289.891 s / epoch.\n",
      "==================== 10 0.141953186972\n",
      "LAST_F1= 0.431080450406\n",
      "update_w= [ 0.14195319 -0.14195319 -0.14195319 -0.14195319 -0.14195319 -0.14195319\n",
      "  0.          0.14195319 -0.14195319  0.         -0.14195319  0.\n",
      "  0.14195319  0.          0.14195319  0.14195319  0.         -0.14195319\n",
      " -0.14195319  0.          0.          0.14195319  0.14195319 -0.14195319\n",
      "  0.14195319  0.          0.14195319 -0.14195319  0.14195319  0.14195319\n",
      "  0.         -0.14195319 -0.14195319 -0.14195319  0.14195319 -0.14195319\n",
      "  0.        ]\n",
      "new_w= [ 13.93688001  12.30945459   3.16529186   5.8412876    7.69912197\n",
      "  -1.03222351   0.91553384  -0.3110676    5.99703012   4.41034378\n",
      "  -1.76191299   1.45625813   7.5800073    2.83585945  -0.4709252\n",
      "   6.18529579   1.24288925   4.85283472   4.43238434   0.3604982\n",
      "   3.61600956  10.10899035   8.25707756  14.24439654   8.29058155\n",
      "   6.76086346   8.72162739   9.19184333  10.36791875   2.82904189\n",
      "   0.28566247  -0.86903417  -5.69430512  -1.98081958   5.71574249\n",
      "   3.55992997   3.88215421]\n",
      "NEW_F1= 0.431085912544\n",
      "**Best_f1=0.431113; Speed: 297.821 s / epoch.\n",
      "==================== 11 0.141243421037\n",
      "LAST_F1= 0.431085912544\n",
      "update_w= [ 0.14124342  0.14124342  0.          0.          0.          0.14124342\n",
      "  0.          0.          0.14124342  0.         -0.14124342  0.\n",
      " -0.14124342  0.          0.          0.14124342  0.          0.          0.\n",
      "  0.14124342  0.14124342  0.14124342 -0.14124342  0.14124342 -0.14124342\n",
      "  0.         -0.14124342  0.14124342 -0.14124342  0.          0.          0.\n",
      "  0.          0.14124342  0.14124342  0.          0.        ]\n",
      "new_w= [ 14.07812343  12.45069801   3.16529186   5.8412876    7.69912197\n",
      "  -0.89098009   0.91553384  -0.3110676    6.13827355   4.41034378\n",
      "  -1.90315641   1.45625813   7.43876388   2.83585945  -0.4709252\n",
      "   6.32653921   1.24288925   4.85283472   4.43238434   0.50174162\n",
      "   3.75725298  10.25023377   8.11583414  14.38563996   8.14933813\n",
      "   6.76086346   8.58038397   9.33308676  10.22667533   2.82904189\n",
      "   0.28566247  -0.86903417  -5.69430512  -1.83957616   5.85698591\n",
      "   3.55992997   3.88215421]\n",
      "NEW_F1= 0.431066750691\n",
      "**Best_f1=0.431113; Speed: 337.697 s / epoch.\n",
      "==================== 12 0.140537203932\n",
      "LAST_F1= 0.431066750691\n",
      "update_w= [ 0.1405372  0.1405372 -0.1405372  0.1405372  0.1405372  0.         0.1405372\n",
      "  0.1405372  0.1405372  0.         0.        -0.1405372  0.1405372  0.\n",
      " -0.1405372  0.1405372  0.1405372  0.1405372  0.        -0.1405372  0.\n",
      " -0.1405372  0.1405372  0.1405372  0.1405372  0.1405372  0.         0.1405372\n",
      "  0.1405372  0.1405372 -0.1405372  0.1405372  0.1405372 -0.1405372\n",
      " -0.1405372  0.1405372 -0.1405372]\n",
      "new_w= [ 14.21866063  12.59123521   3.02475465   5.98182481   7.83965918\n",
      "  -0.89098009   1.05607104  -0.1705304    6.27881075   4.41034378\n",
      "  -1.90315641   1.31572092   7.57930108   2.83585945  -0.6114624\n",
      "   6.46707641   1.38342645   4.99337192   4.43238434   0.36120442\n",
      "   3.75725298  10.10969657   8.25637135  14.52617717   8.28987534\n",
      "   6.90140066   8.58038397   9.47362396  10.36721253   2.96957909\n",
      "   0.14512527  -0.72849696  -5.55376792  -1.98011336   5.7164487\n",
      "   3.70046718   3.741617  ]\n",
      "NEW_F1= 0.431122952355\n",
      "**Best_f1=0.431123; Speed: 282.059 s / epoch.\n",
      "==================== 13 0.139834517912\n",
      "LAST_F1= 0.431122952355\n",
      "update_w= [ 0.          0.13983452  0.13983452  0.13983452  0.          0.13983452\n",
      " -0.13983452 -0.13983452  0.          0.13983452  0.13983452  0.\n",
      "  0.13983452  0.         -0.13983452  0.13983452 -0.13983452  0.13983452\n",
      " -0.13983452  0.          0.13983452  0.13983452  0.13983452  0.\n",
      " -0.13983452  0.13983452  0.13983452  0.13983452  0.13983452  0.13983452\n",
      " -0.13983452  0.13983452  0.13983452  0.13983452  0.13983452  0.13983452\n",
      "  0.13983452]\n",
      "new_w= [  1.42186606e+01   1.27310697e+01   3.16458917e+00   6.12165933e+00\n",
      "   7.83965918e+00  -7.51145575e-01   9.16236526e-01  -3.10364919e-01\n",
      "   6.27881075e+00   4.55017830e+00  -1.76332190e+00   1.31572092e+00\n",
      "   7.71913560e+00   2.83585945e+00  -7.51296920e-01   6.60691093e+00\n",
      "   1.24359193e+00   5.13320644e+00   4.29254982e+00   3.61204416e-01\n",
      "   3.89708750e+00   1.02495311e+01   8.39620586e+00   1.45261772e+01\n",
      "   8.15004082e+00   7.04123518e+00   8.72021849e+00   9.61345848e+00\n",
      "   1.05070470e+01   3.10941361e+00   5.29075090e-03  -5.88662444e-01\n",
      "  -5.41393340e+00  -1.84027885e+00   5.85628322e+00   3.84030170e+00\n",
      "   3.88145152e+00]\n",
      "NEW_F1= 0.431069178339\n",
      "**Best_f1=0.431123; Speed: 260.986 s / epoch.\n",
      "==================== 14 0.139135345323\n",
      "LAST_F1= 0.431069178339\n",
      "update_w= [ 0.13913535  0.13913535  0.13913535  0.13913535 -0.13913535  0.13913535\n",
      "  0.13913535  0.13913535  0.13913535 -0.13913535  0.13913535 -0.13913535\n",
      "  0.13913535 -0.13913535  0.13913535  0.13913535  0.13913535  0.13913535\n",
      "  0.13913535  0.13913535 -0.13913535  0.13913535  0.13913535  0.13913535\n",
      "  0.13913535  0.13913535  0.13913535  0.13913535  0.13913535 -0.13913535\n",
      "  0.13913535  0.13913535  0.13913535  0.13913535  0.13913535  0.13913535\n",
      " -0.13913535]\n",
      "new_w= [ 14.35779598  12.87020507   3.30372451   6.26079467   7.70052383\n",
      "  -0.61201023   1.05537187  -0.17122957   6.41794609   4.41104295\n",
      "  -1.62418655   1.17658558   7.85827094   2.69672411  -0.61216157\n",
      "   6.74604627   1.38272728   5.27234178   4.43168517   0.50033976\n",
      "   3.75795215  10.38866643   8.53534121  14.66531251   8.28917617\n",
      "   7.18037053   8.85935383   9.75259382  10.64618239   2.97027826\n",
      "   0.1444261   -0.4495271   -5.27479805  -1.7011435    5.99541857\n",
      "   3.97943704   3.74231618]\n",
      "NEW_F1= 0.431038534223\n",
      "**Best_f1=0.431123; Speed: 252.901 s / epoch.\n",
      "==================== 15 0.138439668596\n",
      "LAST_F1= 0.431038534223\n",
      "update_w= [ 0.13843967  0.          0.         -0.13843967 -0.13843967 -0.13843967\n",
      " -0.13843967  0.         -0.13843967  0.         -0.13843967 -0.13843967\n",
      " -0.13843967 -0.13843967 -0.13843967 -0.13843967  0.13843967 -0.13843967\n",
      " -0.13843967 -0.13843967  0.          0.13843967  0.13843967  0.13843967\n",
      "  0.          0.         -0.13843967 -0.13843967 -0.13843967 -0.13843967\n",
      " -0.13843967  0.13843967 -0.13843967 -0.13843967  0.13843967 -0.13843967\n",
      "  0.13843967]\n",
      "new_w= [  1.44962356e+01   1.28702051e+01   3.30372451e+00   6.12235500e+00\n",
      "   7.56208416e+00  -7.50449899e-01   9.16932202e-01  -1.71229573e-01\n",
      "   6.27950643e+00   4.41104295e+00  -1.76262622e+00   1.03814591e+00\n",
      "   7.71983128e+00   2.55828444e+00  -7.50601243e-01   6.60760661e+00\n",
      "   1.52116695e+00   5.13390211e+00   4.29324550e+00   3.61900093e-01\n",
      "   3.75795215e+00   1.05271061e+01   8.67378088e+00   1.48037522e+01\n",
      "   8.28917617e+00   7.18037053e+00   8.72091417e+00   9.61415415e+00\n",
      "   1.05077427e+01   2.83183859e+00   5.98642762e-03  -3.11087430e-01\n",
      "  -5.41323772e+00  -1.83958317e+00   6.13385824e+00   3.84099737e+00\n",
      "   3.88075585e+00]\n",
      "NEW_F1= 0.431096021498\n",
      "**Best_f1=0.431123; Speed: 369.268 s / epoch.\n",
      "==================== 16 0.137747470253\n",
      "LAST_F1= 0.431096021498\n",
      "update_w= [ 0.13774747  0.13774747  0.          0.13774747  0.13774747  0.13774747\n",
      "  0.13774747  0.13774747  0.13774747  0.13774747  0.13774747  0.\n",
      " -0.13774747  0.13774747  0.13774747  0.13774747  0.13774747  0.13774747\n",
      "  0.13774747  0.         -0.13774747 -0.13774747 -0.13774747 -0.13774747\n",
      " -0.13774747  0.13774747  0.13774747  0.          0.13774747  0.13774747\n",
      "  0.13774747  0.13774747 -0.13774747  0.13774747  0.13774747 -0.13774747\n",
      "  0.        ]\n",
      "new_w= [ 14.63398311  13.00795254   3.30372451   6.26010247   7.69983163\n",
      "  -0.61270243   1.05467967  -0.0334821    6.4172539    4.54879042\n",
      "  -1.62487875   1.03814591   7.58208381   2.69603191  -0.61285377\n",
      "   6.74535408   1.65891442   5.27164958   4.43099297   0.36190009\n",
      "   3.62020468  10.38935863   8.53603341  14.66600471   8.15142869\n",
      "   7.318118     8.85866164   9.61415415  10.6454902    2.96958606\n",
      "   0.1437339   -0.17333996  -5.55098519  -1.7018357    6.27160571\n",
      "   3.7032499    3.88075585]\n",
      "NEW_F1= 0.431024799586\n",
      "**Best_f1=0.431123; Speed: 315.514 s / epoch.\n",
      "==================== 17 0.137058732902\n",
      "LAST_F1= 0.431024799586\n",
      "update_w= [ 0.13705873  0.          0.         -0.13705873  0.          0.          0.\n",
      "  0.          0.          0.         -0.13705873  0.          0.13705873\n",
      "  0.          0.13705873  0.          0.          0.13705873 -0.13705873\n",
      "  0.          0.          0.13705873  0.13705873  0.13705873  0.          0.\n",
      "  0.          0.13705873  0.          0.          0.          0.\n",
      "  0.13705873  0.13705873  0.13705873  0.13705873  0.        ]\n",
      "new_w= [ 14.77104185  13.00795254   3.30372451   6.12304374   7.69983163\n",
      "  -0.61270243   1.05467967  -0.0334821    6.4172539    4.54879042\n",
      "  -1.76193748   1.03814591   7.71914254   2.69603191  -0.47579504\n",
      "   6.74535408   1.65891442   5.40870832   4.29393424   0.36190009\n",
      "   3.62020468  10.52641736   8.67309214  14.80306344   8.15142869\n",
      "   7.318118     8.85866164   9.75121289  10.6454902    2.96958606\n",
      "   0.1437339   -0.17333996  -5.41392646  -1.56477697   6.40866444\n",
      "   3.84030864   3.88075585]\n",
      "NEW_F1= 0.431036355445\n",
      "**Best_f1=0.431123; Speed: 303.84 s / epoch.\n",
      "==================== 18 0.136373439237\n",
      "LAST_F1= 0.431036355445\n",
      "update_w= [-0.13637344  0.13637344 -0.13637344 -0.13637344  0.13637344 -0.13637344\n",
      " -0.13637344  0.13637344  0.13637344  0.13637344 -0.13637344 -0.13637344\n",
      "  0.13637344 -0.13637344 -0.13637344 -0.13637344 -0.13637344  0.13637344\n",
      "  0.         -0.13637344  0.13637344 -0.13637344  0.13637344  0.13637344\n",
      "  0.13637344  0.13637344 -0.13637344  0.13637344 -0.13637344 -0.13637344\n",
      " -0.13637344 -0.13637344 -0.13637344 -0.13637344 -0.13637344 -0.13637344\n",
      " -0.13637344]\n",
      "new_w= [  1.46346684e+01   1.31443260e+01   3.16735108e+00   5.98667030e+00\n",
      "   7.83620507e+00  -7.49075868e-01   9.18306233e-01   1.02891336e-01\n",
      "   6.55362734e+00   4.68516386e+00  -1.89831092e+00   9.01772470e-01\n",
      "   7.85551598e+00   2.55965847e+00  -6.12168479e-01   6.60898064e+00\n",
      "   1.52254098e+00   5.54508176e+00   4.29393424e+00   2.25526653e-01\n",
      "   3.75657812e+00   1.03900439e+01   8.80946558e+00   1.49394369e+01\n",
      "   8.28780213e+00   7.45449144e+00   8.72228820e+00   9.88758633e+00\n",
      "   1.05091168e+01   2.83321263e+00   7.36045864e-03  -3.09713399e-01\n",
      "  -5.55029990e+00  -1.70115041e+00   6.27229100e+00   3.70393520e+00\n",
      "   3.74438241e+00]\n",
      "NEW_F1= 0.431073009721\n",
      "**Best_f1=0.431123; Speed: 382.844 s / epoch.\n",
      "==================== 19 0.135691572041\n",
      "LAST_F1= 0.431073009721\n",
      "update_w= [ 0.13569157 -0.13569157  0.13569157  0.          0.         -0.13569157\n",
      "  0.          0.          0.         -0.13569157  0.          0.\n",
      "  0.13569157  0.13569157  0.13569157  0.          0.13569157 -0.13569157\n",
      "  0.13569157  0.13569157  0.13569157  0.13569157 -0.13569157  0.\n",
      "  0.13569157  0.13569157  0.13569157  0.         -0.13569157  0.          0.\n",
      "  0.13569157  0.13569157  0.          0.13569157  0.13569157  0.13569157]\n",
      "new_w= [  1.47703600e+01   1.30086344e+01   3.30304265e+00   5.98667030e+00\n",
      "   7.83620507e+00  -8.84767440e-01   9.18306233e-01   1.02891336e-01\n",
      "   6.55362734e+00   4.54947229e+00  -1.89831092e+00   9.01772470e-01\n",
      "   7.99120755e+00   2.69535004e+00  -4.76476907e-01   6.60898064e+00\n",
      "   1.65823255e+00   5.40939019e+00   4.42962581e+00   3.61218225e-01\n",
      "   3.89226970e+00   1.05257355e+01   8.67377401e+00   1.49394369e+01\n",
      "   8.42349371e+00   7.59018301e+00   8.85797977e+00   9.88758633e+00\n",
      "   1.03734252e+01   2.83321263e+00   7.36045864e-03  -1.74021827e-01\n",
      "  -5.41460833e+00  -1.70115041e+00   6.40798257e+00   3.83962677e+00\n",
      "   3.88007398e+00]\n",
      "NEW_F1= 0.431106718505\n",
      "**Best_f1=0.431123; Speed: 285.8 s / epoch.\n",
      "==================== 20 0.135013114181\n",
      "LAST_F1= 0.431106718505\n",
      "update_w= [ 0.13501311  0.          0.          0.          0.          0.          0.\n",
      "  0.13501311  0.          0.13501311  0.          0.13501311  0.13501311\n",
      "  0.          0.          0.          0.          0.          0.          0.\n",
      "  0.         -0.13501311  0.          0.          0.          0.          0.\n",
      "  0.          0.          0.          0.          0.13501311  0.\n",
      " -0.13501311  0.          0.13501311  0.        ]\n",
      "new_w= [  1.49053731e+01   1.30086344e+01   3.30304265e+00   5.98667030e+00\n",
      "   7.83620507e+00  -8.84767440e-01   9.18306233e-01   2.37904450e-01\n",
      "   6.55362734e+00   4.68448540e+00  -1.89831092e+00   1.03678558e+00\n",
      "   8.12622066e+00   2.69535004e+00  -4.76476907e-01   6.60898064e+00\n",
      "   1.65823255e+00   5.40939019e+00   4.42962581e+00   3.61218225e-01\n",
      "   3.89226970e+00   1.03907224e+01   8.67377401e+00   1.49394369e+01\n",
      "   8.42349371e+00   7.59018301e+00   8.85797977e+00   9.88758633e+00\n",
      "   1.03734252e+01   2.83321263e+00   7.36045864e-03  -3.90087127e-02\n",
      "  -5.41460833e+00  -1.83616352e+00   6.40798257e+00   3.97463988e+00\n",
      "   3.88007398e+00]\n",
      "NEW_F1= 0.431098079097\n",
      "**Best_f1=0.431123; Speed: 370.351 s / epoch.\n",
      "==================== 21 0.13433804861\n",
      "LAST_F1= 0.431098079097\n",
      "update_w= [ 0.13433805 -0.13433805  0.          0.13433805 -0.13433805  0.          0.\n",
      " -0.13433805  0.13433805 -0.13433805 -0.13433805 -0.13433805 -0.13433805\n",
      "  0.         -0.13433805 -0.13433805  0.13433805  0.13433805  0.\n",
      " -0.13433805  0.          0.13433805  0.13433805  0.13433805 -0.13433805\n",
      "  0.13433805 -0.13433805  0.13433805  0.13433805  0.13433805  0.\n",
      " -0.13433805  0.13433805 -0.13433805  0.          0.13433805  0.13433805]\n",
      "new_w= [  1.50397111e+01   1.28742964e+01   3.30304265e+00   6.12100835e+00\n",
      "   7.70186702e+00  -8.84767440e-01   9.18306233e-01   1.03566402e-01\n",
      "   6.68796538e+00   4.55014736e+00  -2.03264897e+00   9.02447536e-01\n",
      "   7.99188261e+00   2.69535004e+00  -6.10814956e-01   6.47464259e+00\n",
      "   1.79257060e+00   5.54372823e+00   4.42962581e+00   2.26880177e-01\n",
      "   3.89226970e+00   1.05250604e+01   8.80811206e+00   1.50737749e+01\n",
      "   8.28915566e+00   7.72452106e+00   8.72364172e+00   1.00219244e+01\n",
      "   1.05077632e+01   2.96755067e+00   7.36045864e-03  -1.73346761e-01\n",
      "  -5.28027028e+00  -1.97050157e+00   6.40798257e+00   4.10897793e+00\n",
      "   4.01441203e+00]\n",
      "NEW_F1= 0.431041794872\n",
      "**Best_f1=0.431123; Speed: 366.997 s / epoch.\n",
      "==================== 22 0.133666358367\n",
      "LAST_F1= 0.431041794872\n",
      "update_w= [ 0.13366636  0.13366636  0.13366636  0.13366636  0.13366636  0.13366636\n",
      " -0.13366636  0.13366636  0.13366636  0.13366636  0.13366636  0.13366636\n",
      "  0.13366636 -0.13366636  0.13366636  0.13366636 -0.13366636  0.13366636\n",
      "  0.13366636  0.13366636 -0.13366636  0.13366636 -0.13366636 -0.13366636\n",
      "  0.13366636 -0.13366636  0.13366636  0.13366636  0.13366636  0.13366636\n",
      "  0.13366636  0.13366636 -0.13366636  0.13366636  0.13366636  0.13366636\n",
      "  0.13366636]\n",
      "new_w= [ 15.1733775   13.00796272   3.43670901   6.25467471   7.83553338\n",
      "  -0.75110108   0.78463988   0.23723276   6.82163174   4.68381371\n",
      "  -1.89898261   1.03611389   8.12554897   2.56168368  -0.4771486\n",
      "   6.60830895   1.65890424   5.67739459   4.56329217   0.36054654\n",
      "   3.75860334  10.65872679   8.6744457   14.94010857   8.42282202\n",
      "   7.5908547    8.85730808  10.15559073  10.64142959   3.10121703\n",
      "   0.14102682  -0.0396804   -5.41393664  -1.83683521   6.54164893\n",
      "   4.24264429   4.14807838]\n",
      "NEW_F1= 0.431039318452\n",
      "**Best_f1=0.431123; Speed: 248.132 s / epoch.\n",
      "==================== 23 0.132998026575\n",
      "LAST_F1= 0.431039318452\n",
      "update_w= [ 0.13299803 -0.13299803  0.         -0.13299803 -0.13299803 -0.13299803\n",
      "  0.13299803  0.13299803  0.13299803 -0.13299803 -0.13299803  0.13299803\n",
      " -0.13299803  0.13299803 -0.13299803  0.13299803  0.13299803 -0.13299803\n",
      " -0.13299803  0.13299803  0.13299803  0.13299803  0.13299803 -0.13299803\n",
      "  0.13299803  0.          0.13299803  0.13299803 -0.13299803 -0.13299803\n",
      " -0.13299803 -0.13299803 -0.13299803 -0.13299803 -0.13299803 -0.13299803\n",
      "  0.13299803]\n",
      "new_w= [  1.53063755e+01   1.28749647e+01   3.43670901e+00   6.12167668e+00\n",
      "   7.70253536e+00  -8.84099108e-01   9.17637902e-01   3.70230787e-01\n",
      "   6.95462977e+00   4.55081569e+00  -2.03198064e+00   1.16911192e+00\n",
      "   7.99255095e+00   2.69468171e+00  -6.10146624e-01   6.74130697e+00\n",
      "   1.79190227e+00   5.54439657e+00   4.43029414e+00   4.93544562e-01\n",
      "   3.89160136e+00   1.07917248e+01   8.80744372e+00   1.48071105e+01\n",
      "   8.55582004e+00   7.59085470e+00   8.99030611e+00   1.02885888e+01\n",
      "   1.05084316e+01   2.96821901e+00   8.02879043e-03  -1.72678429e-01\n",
      "  -5.54693466e+00  -1.96983324e+00   6.40865090e+00   4.10964626e+00\n",
      "   4.28107641e+00]\n",
      "NEW_F1= 0.431065890417\n",
      "**Best_f1=0.431123; Speed: 311.122 s / epoch.\n",
      "==================== 24 0.132333036442\n",
      "LAST_F1= 0.431065890417\n",
      "update_w= [ 0.13233304  0.13233304  0.          0.          0.          0.\n",
      "  0.13233304  0.13233304  0.          0.          0.          0.\n",
      "  0.13233304  0.13233304 -0.13233304  0.         -0.13233304  0.\n",
      "  0.13233304  0.          0.         -0.13233304 -0.13233304  0.          0.\n",
      "  0.         -0.13233304 -0.13233304  0.         -0.13233304  0.          0.\n",
      "  0.13233304  0.          0.          0.          0.        ]\n",
      "new_w= [  1.54387086e+01   1.30072977e+01   3.43670901e+00   6.12167668e+00\n",
      "   7.70253536e+00  -8.84099108e-01   1.04997094e+00   5.02563823e-01\n",
      "   6.95462977e+00   4.55081569e+00  -2.03198064e+00   1.16911192e+00\n",
      "   8.12488398e+00   2.82701475e+00  -7.42479661e-01   6.74130697e+00\n",
      "   1.65956923e+00   5.54439657e+00   4.56262718e+00   4.93544562e-01\n",
      "   3.89160136e+00   1.06593918e+01   8.67511069e+00   1.48071105e+01\n",
      "   8.55582004e+00   7.59085470e+00   8.85797307e+00   1.01562557e+01\n",
      "   1.05084316e+01   2.83588597e+00   8.02879043e-03  -1.72678429e-01\n",
      "  -5.41460163e+00  -1.96983324e+00   6.40865090e+00   4.10964626e+00\n",
      "   4.28107641e+00]\n",
      "NEW_F1= 0.431095236556\n",
      "**Best_f1=0.431123; Speed: 351.272 s / epoch.\n",
      "==================== 25 0.13167137126\n",
      "LAST_F1= 0.431095236556\n",
      "update_w= [-0.13167137 -0.13167137  0.13167137  0.         -0.13167137 -0.13167137\n",
      "  0.13167137  0.          0.13167137  0.         -0.13167137 -0.13167137\n",
      "  0.13167137  0.         -0.13167137  0.13167137  0.          0.\n",
      " -0.13167137  0.          0.          0.13167137  0.13167137  0.13167137\n",
      "  0.13167137  0.13167137  0.13167137 -0.13167137  0.          0.          0.\n",
      " -0.13167137  0.          0.         -0.13167137  0.13167137 -0.13167137]\n",
      "new_w= [  1.53070372e+01   1.28756264e+01   3.56838038e+00   6.12167668e+00\n",
      "   7.57086398e+00  -1.01577048e+00   1.18164231e+00   5.02563823e-01\n",
      "   7.08630114e+00   4.55081569e+00  -2.16365201e+00   1.03744055e+00\n",
      "   8.25655535e+00   2.82701475e+00  -8.74151032e-01   6.87297834e+00\n",
      "   1.65956923e+00   5.54439657e+00   4.43095581e+00   4.93544562e-01\n",
      "   3.89160136e+00   1.07910632e+01   8.80678206e+00   1.49387819e+01\n",
      "   8.68749141e+00   7.72252607e+00   8.98964444e+00   1.00245844e+01\n",
      "   1.05084316e+01   2.83588597e+00   8.02879043e-03  -3.04349801e-01\n",
      "  -5.41460163e+00  -1.96983324e+00   6.27697953e+00   4.24131763e+00\n",
      "   4.14940504e+00]\n",
      "NEW_F1= 0.431108653519\n",
      "**Best_f1=0.431123; Speed: 260.225 s / epoch.\n",
      "==================== 26 0.131013014404\n",
      "LAST_F1= 0.431108653519\n",
      "update_w= [ 0.          0.          0.          0.          0.          0.13101301\n",
      " -0.13101301  0.13101301  0.          0.          0.13101301  0.13101301\n",
      " -0.13101301  0.13101301  0.          0.          0.          0.          0.\n",
      "  0.          0.          0.          0.          0.          0.\n",
      " -0.13101301  0.          0.13101301  0.          0.13101301  0.          0.\n",
      "  0.         -0.13101301  0.          0.          0.13101301]\n",
      "new_w= [  1.53070372e+01   1.28756264e+01   3.56838038e+00   6.12167668e+00\n",
      "   7.57086398e+00  -8.84757465e-01   1.05062929e+00   6.33576837e-01\n",
      "   7.08630114e+00   4.55081569e+00  -2.03263900e+00   1.16845356e+00\n",
      "   8.12554234e+00   2.95802776e+00  -8.74151032e-01   6.87297834e+00\n",
      "   1.65956923e+00   5.54439657e+00   4.43095581e+00   4.93544562e-01\n",
      "   3.89160136e+00   1.07910632e+01   8.80678206e+00   1.49387819e+01\n",
      "   8.68749141e+00   7.59151306e+00   8.98964444e+00   1.01555974e+01\n",
      "   1.05084316e+01   2.96689898e+00   8.02879043e-03  -3.04349801e-01\n",
      "  -5.41460163e+00  -2.10084625e+00   6.27697953e+00   4.24131763e+00\n",
      "   4.28041805e+00]\n",
      "NEW_F1= 0.43109780214\n",
      "**Best_f1=0.431123; Speed: 357.868 s / epoch.\n",
      "==================== 27 0.130357949332\n",
      "LAST_F1= 0.43109780214\n",
      "update_w= [ 0.13035795  0.13035795  0.13035795  0.13035795 -0.13035795  0.13035795\n",
      "  0.13035795  0.13035795 -0.13035795  0.13035795 -0.13035795 -0.13035795\n",
      "  0.13035795 -0.13035795  0.13035795  0.13035795  0.13035795 -0.13035795\n",
      "  0.13035795 -0.13035795 -0.13035795  0.13035795  0.13035795 -0.13035795\n",
      " -0.13035795  0.13035795  0.13035795  0.13035795  0.13035795  0.13035795\n",
      " -0.13035795  0.13035795  0.13035795  0.13035795  0.13035795  0.13035795\n",
      " -0.13035795]\n",
      "new_w= [ 15.43739514  13.00598431   3.69873833   6.25203463   7.44050604\n",
      "  -0.75439952   1.18098724   0.76393479   6.95594319   4.68117364\n",
      "  -2.16299694   1.03809561   8.25590029   2.82766981  -0.74379308\n",
      "   7.00333629   1.78992718   5.41403862   4.56131375   0.36318661\n",
      "   3.76124341  10.9214211    8.93714001  14.80842397   8.55713346\n",
      "   7.72187101   9.12000239  10.28595532  10.63878951   3.09725693\n",
      "  -0.12232916  -0.17399185  -5.28424368  -1.9704883    6.40733748\n",
      "   4.37167558   4.15006011]\n",
      "NEW_F1= 0.431043934056\n",
      "**Best_f1=0.431123; Speed: 255.288 s / epoch.\n",
      "==================== 28 0.129706159585\n",
      "LAST_F1= 0.431043934056\n",
      "update_w= [ 0.          0.12970616  0.12970616 -0.12970616  0.12970616  0.12970616\n",
      "  0.          0.12970616  0.         -0.12970616  0.12970616  0.12970616\n",
      "  0.12970616  0.12970616 -0.12970616 -0.12970616  0.12970616 -0.12970616\n",
      "  0.12970616 -0.12970616  0.12970616  0.12970616  0.12970616  0.12970616\n",
      "  0.12970616  0.12970616  0.          0.          0.         -0.12970616\n",
      "  0.12970616  0.          0.12970616 -0.12970616 -0.12970616 -0.12970616\n",
      "  0.12970616]\n",
      "new_w= [  1.54373951e+01   1.31356905e+01   3.82844449e+00   6.12232847e+00\n",
      "   7.57021220e+00  -6.24693356e-01   1.18098724e+00   8.93640946e-01\n",
      "   6.95594319e+00   4.55146748e+00  -2.03329078e+00   1.16780177e+00\n",
      "   8.38560645e+00   2.95737597e+00  -8.73499242e-01   6.87363013e+00\n",
      "   1.91963334e+00   5.28433246e+00   4.69101991e+00   2.33480453e-01\n",
      "   3.89094957e+00   1.10511273e+01   9.06684617e+00   1.49381301e+01\n",
      "   8.68683962e+00   7.85157717e+00   9.12000239e+00   1.02859553e+01\n",
      "   1.06387895e+01   2.96755077e+00   7.37700068e-03  -1.73991851e-01\n",
      "  -5.15453752e+00  -2.10019446e+00   6.27763132e+00   4.24196942e+00\n",
      "   4.27976626e+00]\n",
      "NEW_F1= 0.431049360083\n",
      "**Best_f1=0.431123; Speed: 292.793 s / epoch.\n",
      "==================== 29 0.129057628787\n",
      "LAST_F1= 0.431049360083\n",
      "update_w= [ 0.          0.12905763 -0.12905763  0.12905763  0.12905763  0.12905763\n",
      "  0.12905763 -0.12905763 -0.12905763 -0.12905763  0.12905763  0.12905763\n",
      "  0.12905763  0.         -0.12905763  0.12905763  0.12905763  0.12905763\n",
      "  0.12905763  0.         -0.12905763 -0.12905763  0.12905763  0.12905763\n",
      "  0.12905763  0.12905763  0.12905763  0.12905763  0.12905763 -0.12905763\n",
      " -0.12905763 -0.12905763  0.12905763  0.12905763  0.12905763  0.12905763\n",
      " -0.12905763]\n",
      "new_w= [ 15.43739514  13.2647481    3.69938686   6.2513861    7.69926982\n",
      "  -0.49563573   1.31004487   0.76458332   6.82688556   4.42240985\n",
      "  -1.90423316   1.2968594    8.51466408   2.95737597  -1.00255687\n",
      "   7.00268776   2.04869097   5.41339009   4.82007754   0.23348045\n",
      "   3.76189194  10.92206963   9.1959038   15.06718776   8.81589725\n",
      "   7.98063479   9.24906002  10.41501295  10.76784714   2.83849314\n",
      "  -0.12168063  -0.30304948  -5.02547989  -1.97113683   6.40668895\n",
      "   4.37102705   4.15070864]\n",
      "NEW_F1= 0.431053135687\n",
      "**Best_f1=0.431123; Speed: 229.867 s / epoch.\n",
      "==================== 30 0.128412340643\n",
      "LAST_F1= 0.431053135687\n",
      "update_w= [ 0.12841234 -0.12841234  0.12841234  0.12841234  0.12841234  0.12841234\n",
      "  0.12841234  0.12841234  0.12841234  0.12841234  0.12841234  0.12841234\n",
      "  0.12841234 -0.12841234  0.12841234  0.12841234 -0.12841234  0.12841234\n",
      "  0.12841234  0.12841234  0.12841234  0.12841234 -0.12841234  0.12841234\n",
      " -0.12841234 -0.12841234  0.12841234 -0.12841234  0.12841234  0.12841234\n",
      " -0.12841234 -0.12841234 -0.12841234 -0.12841234  0.12841234 -0.12841234\n",
      "  0.12841234]\n",
      "new_w= [ 15.56580748  13.13633576   3.8277992    6.37979844   7.82768216\n",
      "  -0.36722339   1.43845721   0.89299566   6.9552979    4.55082219\n",
      "  -1.77582082   1.42527174   8.64307642   2.82896363  -0.87414453\n",
      "   7.1311001    1.92027863   5.54180243   4.94848988   0.36189279\n",
      "   3.89030429  11.05048197   9.06749146  15.1956001    8.68748491\n",
      "   7.85222245   9.37747236  10.2866006   10.89625948   2.96690549\n",
      "  -0.25009297  -0.43146182  -5.15389223  -2.09954917   6.53510129\n",
      "   4.24261471   4.27912098]\n",
      "NEW_F1= 0.43106007924\n",
      "**Best_f1=0.431123; Speed: 223.594 s / epoch.\n",
      "==================== 31 0.12777027894\n",
      "LAST_F1= 0.43106007924\n",
      "update_w= [ 0.          0.12777028  0.          0.          0.          0.          0.\n",
      "  0.          0.          0.12777028  0.          0.          0.          0.\n",
      "  0.          0.          0.          0.          0.          0.12777028\n",
      "  0.          0.          0.          0.          0.12777028  0.\n",
      " -0.12777028  0.          0.         -0.12777028 -0.12777028  0.          0.\n",
      "  0.          0.          0.          0.12777028]\n",
      "new_w= [ 15.56580748  13.26410604   3.8277992    6.37979844   7.82768216\n",
      "  -0.36722339   1.43845721   0.89299566   6.9552979    4.67859247\n",
      "  -1.77582082   1.42527174   8.64307642   2.82896363  -0.87414453\n",
      "   7.1311001    1.92027863   5.54180243   4.94848988   0.48966307\n",
      "   3.89030429  11.05048197   9.06749146  15.1956001    8.81525519\n",
      "   7.85222245   9.24970208  10.2866006   10.89625948   2.83913521\n",
      "  -0.37786325  -0.43146182  -5.15389223  -2.09954917   6.53510129\n",
      "   4.24261471   4.40689126]\n",
      "NEW_F1= 0.431055190241\n",
      "**Best_f1=0.431123; Speed: 334.936 s / epoch.\n",
      "==================== 32 0.127131427545\n",
      "LAST_F1= 0.431055190241\n",
      "update_w= [ 0.12713143 -0.12713143 -0.12713143 -0.12713143 -0.12713143 -0.12713143\n",
      " -0.12713143 -0.12713143 -0.12713143 -0.12713143 -0.12713143  0.\n",
      "  0.12713143  0.12713143 -0.12713143 -0.12713143 -0.12713143  0.\n",
      "  0.12713143 -0.12713143  0.12713143  0.12713143  0.12713143  0.12713143\n",
      "  0.         -0.12713143  0.12713143  0.12713143  0.12713143 -0.12713143\n",
      "  0.12713143 -0.12713143  0.12713143 -0.12713143 -0.12713143 -0.12713143\n",
      " -0.12713143]\n",
      "new_w= [ 15.69293891  13.13697461   3.70066777   6.25266701   7.70055074\n",
      "  -0.49435481   1.31132579   0.76586423   6.82816648   4.55146104\n",
      "  -1.90295224   1.42527174   8.77020785   2.95609506  -1.00127596\n",
      "   7.00396868   1.7931472    5.54180243   5.07562131   0.36253164\n",
      "   4.01743571  11.1776134    9.19462288  15.32273152   8.81525519\n",
      "   7.72509103   9.37683351  10.41373203  11.02339091   2.71200378\n",
      "  -0.25073182  -0.55859325  -5.0267608   -2.2266806    6.40796986\n",
      "   4.11548328   4.27975983]\n",
      "NEW_F1= 0.43107994384\n",
      "**Best_f1=0.431123; Speed: 282.309 s / epoch.\n",
      "==================== 33 0.126495770408\n",
      "LAST_F1= 0.43107994384\n",
      "update_w= [ 0.12649577  0.          0.12649577  0.12649577  0.12649577  0.          0.\n",
      "  0.12649577  0.12649577  0.12649577  0.12649577 -0.12649577 -0.12649577\n",
      " -0.12649577  0.12649577  0.          0.12649577 -0.12649577  0.          0.\n",
      "  0.          0.12649577  0.          0.          0.12649577  0.12649577\n",
      "  0.          0.         -0.12649577 -0.12649577 -0.12649577  0.\n",
      "  0.12649577  0.          0.          0.          0.        ]\n",
      "new_w= [ 15.81943468  13.13697461   3.82716354   6.37916278   7.82704651\n",
      "  -0.49435481   1.31132579   0.89236      6.95466225   4.67795681\n",
      "  -1.77645647   1.29877597   8.64371208   2.82959929  -0.87478019\n",
      "   7.00396868   1.91964297   5.41530666   5.07562131   0.36253164\n",
      "   4.01743571  11.30410917   9.19462288  15.32273152   8.94175096\n",
      "   7.8515868    9.37683351  10.41373203  10.89689514   2.58550801\n",
      "  -0.37722759  -0.55859325  -4.90026503  -2.2266806    6.40796986\n",
      "   4.11548328   4.27975983]\n",
      "NEW_F1= 0.431121247674\n",
      "**Best_f1=0.431123; Speed: 306.681 s / epoch.\n",
      "==================== 34 0.125863291556\n",
      "LAST_F1= 0.431121247674\n",
      "update_w= [-0.12586329  0.12586329  0.          0.          0.         -0.12586329\n",
      "  0.12586329  0.         -0.12586329 -0.12586329  0.         -0.12586329\n",
      "  0.          0.         -0.12586329  0.         -0.12586329  0.12586329\n",
      " -0.12586329  0.          0.          0.         -0.12586329  0.12586329\n",
      "  0.          0.          0.         -0.12586329  0.          0.\n",
      " -0.12586329 -0.12586329  0.          0.12586329  0.          0.\n",
      " -0.12586329]\n",
      "new_w= [ 15.69357139  13.2628379    3.82716354   6.37916278   7.82704651\n",
      "  -0.62021811   1.43718908   0.89236      6.82879895   4.55209352\n",
      "  -1.77645647   1.17291268   8.64371208   2.82959929  -1.00064348\n",
      "   7.00396868   1.79377968   5.54116995   4.94975802   0.36253164\n",
      "   4.01743571  11.30410917   9.06875959  15.44859482   8.94175096\n",
      "   7.8515868    9.37683351  10.28786874  10.89689514   2.58550801\n",
      "  -0.50309088  -0.68445654  -4.90026503  -2.10081731   6.40796986\n",
      "   4.11548328   4.15389654]\n",
      "NEW_F1= 0.43110237593\n",
      "**Best_f1=0.431123; Speed: 383.14 s / epoch.\n",
      "==================== 35 0.125233975098\n",
      "LAST_F1= 0.43110237593\n",
      "update_w= [ 0.          0.12523398  0.12523398  0.12523398  0.12523398  0.12523398\n",
      " -0.12523398 -0.12523398  0.12523398  0.12523398  0.12523398  0.12523398\n",
      "  0.12523398  0.12523398  0.12523398  0.12523398  0.12523398 -0.12523398\n",
      "  0.12523398  0.12523398  0.12523398 -0.12523398  0.12523398 -0.12523398\n",
      "  0.12523398  0.         -0.12523398  0.12523398  0.12523398  0.12523398\n",
      "  0.12523398  0.12523398  0.          0.12523398  0.12523398  0.12523398\n",
      " -0.12523398]\n",
      "new_w= [ 15.69357139  13.38807187   3.95239752   6.50439676   7.95228048\n",
      "  -0.49498413   1.3119551    0.76712603   6.95403293   4.67732749\n",
      "  -1.6512225    1.29814666   8.76894605   2.95483326  -0.8754095\n",
      "   7.12920265   1.91901365   5.41593597   5.07499199   0.48776562\n",
      "   4.14266969  11.17887519   9.19399357  15.32336084   9.06698494\n",
      "   7.8515868    9.25159953  10.41310272  11.02212912   2.71074198\n",
      "  -0.37785691  -0.55922256  -4.90026503  -1.97558333   6.53320384\n",
      "   4.24071726   4.02866256]\n",
      "NEW_F1= 0.431046292339\n",
      "**Best_f1=0.431123; Speed: 256.151 s / epoch.\n",
      "==================== 36 0.124607805222\n",
      "LAST_F1= 0.431046292339\n",
      "update_w= [ 0.12460781  0.          0.          0.         -0.12460781  0.\n",
      "  0.12460781  0.          0.         -0.12460781  0.          0.\n",
      "  0.12460781 -0.12460781 -0.12460781  0.          0.          0.12460781\n",
      "  0.12460781 -0.12460781 -0.12460781  0.         -0.12460781  0.          0.\n",
      "  0.12460781  0.12460781  0.         -0.12460781 -0.12460781 -0.12460781\n",
      "  0.         -0.12460781 -0.12460781 -0.12460781  0.          0.        ]\n",
      "new_w= [ 15.81817919  13.38807187   3.95239752   6.50439676   7.82767268\n",
      "  -0.49498413   1.43656291   0.76712603   6.95403293   4.55271969\n",
      "  -1.6512225    1.29814666   8.89355386   2.83022546  -1.00001731\n",
      "   7.12920265   1.91901365   5.54054378   5.1995998    0.36315781\n",
      "   4.01806188  11.17887519   9.06938576  15.32336084   9.06698494\n",
      "   7.9761946    9.37620734  10.41310272  10.89752131   2.58613418\n",
      "  -0.50246471  -0.55922256  -5.02487284  -2.10019114   6.40859603\n",
      "   4.24071726   4.02866256]\n",
      "NEW_F1= 0.431092063778\n",
      "**Best_f1=0.431123; Speed: 361.972 s / epoch.\n",
      "==================== 37 0.123984766196\n",
      "LAST_F1= 0.431092063778\n",
      "update_w= [ 0.12398477  0.12398477 -0.12398477 -0.12398477  0.12398477  0.12398477\n",
      " -0.12398477 -0.12398477  0.          0.          0.          0.12398477\n",
      " -0.12398477  0.12398477  0.12398477  0.12398477 -0.12398477 -0.12398477\n",
      "  0.12398477 -0.12398477  0.12398477  0.12398477  0.12398477  0.12398477\n",
      " -0.12398477  0.12398477  0.          0.12398477 -0.12398477 -0.12398477\n",
      "  0.12398477  0.12398477 -0.12398477  0.12398477  0.12398477  0.12398477\n",
      " -0.12398477]\n",
      "new_w= [ 15.94216396  13.51205664   3.82841275   6.38041199   7.95165744\n",
      "  -0.37099936   1.31257814   0.64314126   6.95403293   4.55271969\n",
      "  -1.6512225    1.42213142   8.76956909   2.95421022  -0.87603254\n",
      "   7.25318742   1.79502889   5.41655901   5.32358457   0.23917305\n",
      "   4.14204665  11.30285996   9.19337053  15.44734561   8.94300017\n",
      "   8.10017937   9.37620734  10.53708748  10.77353654   2.46214941\n",
      "  -0.37847995  -0.4352378   -5.1488576   -1.97620637   6.5325808\n",
      "   4.36470203   3.9046778 ]\n",
      "NEW_F1= 0.431079471097\n",
      "**Best_f1=0.431123; Speed: 376.694 s / epoch.\n",
      "==================== 38 0.123364842365\n",
      "LAST_F1= 0.431079471097\n",
      "update_w= [-0.12336484  0.         -0.12336484  0.12336484  0.          0.          0.\n",
      "  0.          0.          0.         -0.12336484  0.          0.          0.\n",
      " -0.12336484 -0.12336484  0.         -0.12336484 -0.12336484  0.\n",
      " -0.12336484  0.          0.          0.          0.12336484 -0.12336484\n",
      "  0.          0.          0.          0.         -0.12336484 -0.12336484\n",
      "  0.         -0.12336484  0.         -0.12336484  0.        ]\n",
      "new_w= [ 15.81879912  13.51205664   3.70504791   6.50377683   7.95165744\n",
      "  -0.37099936   1.31257814   0.64314126   6.95403293   4.55271969\n",
      "  -1.77458734   1.42213142   8.76956909   2.95421022  -0.99939739\n",
      "   7.12982257   1.79502889   5.29319417   5.20021972   0.23917305\n",
      "   4.01868181  11.30285996   9.19337053  15.44734561   9.06636501\n",
      "   7.97681453   9.37620734  10.53708748  10.77353654   2.46214941\n",
      "  -0.50184479  -0.55860264  -5.1488576   -2.09957122   6.5325808\n",
      "   4.24133718   3.9046778 ]\n",
      "NEW_F1= 0.431080731464\n",
      "**Best_f1=0.431123; Speed: 472.713 s / epoch.\n",
      "==================== 39 0.122748018153\n",
      "LAST_F1= 0.431080731464\n",
      "update_w= [-0.12274802  0.12274802  0.12274802  0.12274802  0.12274802  0.12274802\n",
      "  0.12274802 -0.12274802  0.12274802  0.12274802  0.12274802  0.12274802\n",
      "  0.12274802 -0.12274802  0.12274802  0.12274802  0.12274802  0.12274802\n",
      "  0.12274802  0.12274802  0.12274802  0.12274802  0.12274802  0.12274802\n",
      "  0.          0.12274802 -0.12274802  0.12274802  0.12274802  0.12274802\n",
      "  0.12274802  0.12274802  0.12274802  0.12274802  0.12274802  0.12274802\n",
      "  0.12274802]\n",
      "new_w= [ 15.6960511   13.63480466   3.82779593   6.62652485   8.07440546\n",
      "  -0.24825135   1.43532616   0.52039324   7.07678095   4.67546771\n",
      "  -1.65183932   1.54487944   8.89231711   2.8314622   -0.87664937\n",
      "   7.25257059   1.91777691   5.41594219   5.32296774   0.36192107\n",
      "   4.14142982  11.42560798   9.31611855  15.57009362   9.06636501\n",
      "   8.09956254   9.25345932  10.6598355   10.89628456   2.58489743\n",
      "  -0.37909677  -0.43585462  -5.02610959  -1.9768232    6.65532882\n",
      "   4.3640852    4.02742581]\n",
      "NEW_F1= 0.431032126333\n",
      "**Best_f1=0.431123; Speed: 234.09 s / epoch.\n",
      "==================== 40 0.122134278063\n",
      "LAST_F1= 0.431032126333\n",
      "update_w= [ 0.12213428  0.12213428 -0.12213428 -0.12213428 -0.12213428 -0.12213428\n",
      "  0.12213428  0.12213428 -0.12213428  0.         -0.12213428 -0.12213428\n",
      " -0.12213428 -0.12213428 -0.12213428 -0.12213428 -0.12213428  0.12213428\n",
      "  0.12213428  0.12213428 -0.12213428  0.12213428  0.12213428  0.\n",
      "  0.12213428  0.12213428  0.12213428 -0.12213428 -0.12213428 -0.12213428\n",
      " -0.12213428 -0.12213428 -0.12213428 -0.12213428  0.12213428 -0.12213428\n",
      " -0.12213428]\n",
      "new_w= [ 15.81818538  13.75693894   3.70566165   6.50439057   7.95227118\n",
      "  -0.37038562   1.55746044   0.64252752   6.95464667   4.67546771\n",
      "  -1.7739736    1.42274516   8.77018283   2.70932793  -0.99878365\n",
      "   7.13043632   1.79564263   5.53807646   5.44510202   0.48405534\n",
      "   4.01929555  11.54774226   9.43825282  15.57009362   9.18849929\n",
      "   8.22169682   9.3755936   10.53770122  10.77415028   2.46276315\n",
      "  -0.50123105  -0.5579889   -5.14824386  -2.09895748   6.7774631\n",
      "   4.24195092   3.90529154]\n",
      "NEW_F1= 0.431060984138\n",
      "**Best_f1=0.431123; Speed: 356.14 s / epoch.\n",
      "==================== 41 0.121523606672\n",
      "LAST_F1= 0.431060984138\n",
      "update_w= [ 0.         -0.12152361 -0.12152361  0.          0.12152361  0.\n",
      "  0.12152361  0.12152361  0.12152361  0.12152361 -0.12152361 -0.12152361\n",
      "  0.12152361  0.12152361  0.12152361  0.12152361 -0.12152361 -0.12152361\n",
      "  0.          0.12152361  0.          0.         -0.12152361  0.\n",
      " -0.12152361  0.12152361  0.12152361  0.12152361  0.          0.12152361\n",
      "  0.12152361  0.12152361  0.12152361  0.12152361 -0.12152361  0.12152361\n",
      " -0.12152361]\n",
      "new_w= [ 15.81818538  13.63541533   3.58413804   6.50439057   8.07379479\n",
      "  -0.37038562   1.67898404   0.76405113   7.07617028   4.79699131\n",
      "  -1.89549721   1.30122156   8.89170644   2.83085153  -0.87726004\n",
      "   7.25195992   1.67411902   5.41655286   5.44510202   0.60557895\n",
      "   4.01929555  11.54774226   9.31672922  15.57009362   9.06697568\n",
      "   8.34322043   9.4971172   10.65922483  10.77415028   2.58428676\n",
      "  -0.37970744  -0.43646529  -5.02672026  -1.97743387   6.65593949\n",
      "   4.36347453   3.78376793]\n",
      "NEW_F1= 0.431046487895\n",
      "**Best_f1=0.431123; Speed: 272.094 s / epoch.\n",
      "==================== 42 0.120915988639\n",
      "LAST_F1= 0.431046487895\n",
      "update_w= [ 0.12091599 -0.12091599  0.         -0.12091599  0.12091599  0.\n",
      " -0.12091599  0.         -0.12091599 -0.12091599 -0.12091599  0.\n",
      "  0.12091599 -0.12091599  0.          0.          0.12091599  0.\n",
      " -0.12091599  0.         -0.12091599  0.          0.12091599  0.12091599\n",
      "  0.12091599 -0.12091599  0.          0.          0.         -0.12091599\n",
      "  0.         -0.12091599  0.          0.12091599  0.          0.\n",
      "  0.12091599]\n",
      "new_w= [ 15.93910137  13.51449934   3.58413804   6.38347459   8.19471078\n",
      "  -0.37038562   1.55806806   0.76405113   6.95525429   4.67607532\n",
      "  -2.01641319   1.30122156   9.01262242   2.70993554  -0.87726004\n",
      "   7.25195992   1.79503501   5.41655286   5.32418603   0.60557895\n",
      "   3.89837956  11.54774226   9.43764521  15.69100961   9.18789167\n",
      "   8.22230444   9.4971172   10.65922483  10.77415028   2.46337077\n",
      "  -0.37970744  -0.55738128  -5.02672026  -1.85651788   6.65593949\n",
      "   4.36347453   3.90468392]\n",
      "NEW_F1= 0.431084541025\n",
      "**Best_f1=0.431123; Speed: 409.604 s / epoch.\n",
      "==================== 43 0.120311408696\n",
      "LAST_F1= 0.431084541025\n",
      "update_w= [ 0.          0.12031141 -0.12031141 -0.12031141 -0.12031141  0.12031141\n",
      " -0.12031141 -0.12031141  0.         -0.12031141 -0.12031141 -0.12031141\n",
      "  0.          0.         -0.12031141  0.12031141  0.12031141  0.\n",
      "  0.12031141  0.12031141  0.12031141  0.12031141  0.12031141  0.12031141\n",
      "  0.12031141 -0.12031141  0.          0.         -0.12031141  0.\n",
      "  0.12031141  0.12031141 -0.12031141  0.         -0.12031141  0.          0.        ]\n",
      "new_w= [ 15.93910137  13.63481075   3.46382663   6.26316318   8.07439937\n",
      "  -0.25007422   1.43775665   0.64373972   6.95525429   4.55576392\n",
      "  -2.1367246    1.18091015   9.01262242   2.70993554  -0.99757145\n",
      "   7.37227133   1.91534642   5.41655286   5.44449744   0.72589036\n",
      "   4.01869097  11.66805366   9.55795662  15.81132102   9.30820308\n",
      "   8.10199303   9.4971172   10.65922483  10.65383888   2.46337077\n",
      "  -0.25939603  -0.43706987  -5.14703167  -1.85651788   6.53562808\n",
      "   4.36347453   3.90468392]\n",
      "NEW_F1= 0.431041358052\n",
      "**Best_f1=0.431123; Speed: 398.544 s / epoch.\n",
      "==================== 44 0.119709851652\n",
      "LAST_F1= 0.431041358052\n",
      "update_w= [ 0.11970985  0.11970985  0.11970985  0.11970985  0.11970985  0.11970985\n",
      "  0.          0.11970985  0.11970985  0.11970985  0.11970985  0.11970985\n",
      " -0.11970985  0.11970985  0.11970985  0.11970985  0.11970985  0.11970985\n",
      "  0.11970985  0.11970985 -0.11970985  0.11970985  0.11970985  0.11970985\n",
      "  0.11970985 -0.11970985  0.11970985  0.11970985  0.11970985  0.11970985\n",
      "  0.11970985  0.11970985 -0.11970985 -0.11970985  0.11970985  0.11970985\n",
      "  0.11970985]\n",
      "new_w= [ 16.05881122  13.7545206    3.58353648   6.38287303   8.19410922\n",
      "  -0.13036436   1.43775665   0.76344957   7.07496414   4.67547377\n",
      "  -2.01701475   1.30062      8.89291257   2.8296454   -0.8778616\n",
      "   7.49198118   2.03505627   5.53626271   5.56420729   0.84560021\n",
      "   3.89898112  11.78776352   9.67766647  15.93103087   9.42791293\n",
      "   7.98228318   9.61682706  10.77893468  10.77354873   2.58308062\n",
      "  -0.13968618  -0.31736002  -5.26674152  -1.97622773   6.65533793\n",
      "   4.48318438   4.02439377]\n",
      "NEW_F1= 0.431066045122\n",
      "**Best_f1=0.431123; Speed: 277.53 s / epoch.\n",
      "==================== 45 0.119111302394\n",
      "LAST_F1= 0.431066045122\n",
      "update_w= [ 0.         0.         0.1191113  0.1191113  0.         0.1191113  0.         0.\n",
      " -0.1191113  0.         0.1191113  0.1191113  0.         0.        -0.1191113\n",
      "  0.         0.         0.         0.         0.         0.         0.         0.\n",
      "  0.         0.         0.        -0.1191113  0.         0.         0.1191113\n",
      "  0.         0.1191113  0.         0.         0.         0.         0.       ]\n",
      "new_w= [  1.60588112e+01   1.37545206e+01   3.70264779e+00   6.50198433e+00\n",
      "   8.19410922e+00  -1.12530613e-02   1.43775665e+00   7.63449569e-01\n",
      "   6.95585284e+00   4.67547377e+00  -1.89790345e+00   1.41973130e+00\n",
      "   8.89291257e+00   2.82964540e+00  -9.96972898e-01   7.49198118e+00\n",
      "   2.03505627e+00   5.53626271e+00   5.56420729e+00   8.45600212e-01\n",
      "   3.89898112e+00   1.17877635e+01   9.67766647e+00   1.59310309e+01\n",
      "   9.42791293e+00   7.98228318e+00   9.49771575e+00   1.07789347e+01\n",
      "   1.07735487e+01   2.70219192e+00  -1.39686181e-01  -1.98248720e-01\n",
      "  -5.26674152e+00  -1.97622773e+00   6.65533793e+00   4.48318438e+00\n",
      "   4.02439377e+00]\n",
      "NEW_F1= 0.431052336664\n",
      "**Best_f1=0.431123; Speed: 424.82 s / epoch.\n",
      "==================== 46 0.118515745882\n",
      "LAST_F1= 0.431052336664\n",
      "update_w= [ 0.11851575  0.          0.         -0.11851575  0.11851575 -0.11851575\n",
      "  0.          0.          0.11851575  0.          0.11851575  0.          0.\n",
      "  0.          0.          0.          0.         -0.11851575  0.\n",
      " -0.11851575  0.11851575  0.11851575  0.          0.          0.11851575\n",
      "  0.          0.11851575  0.          0.         -0.11851575 -0.11851575\n",
      " -0.11851575 -0.11851575 -0.11851575 -0.11851575 -0.11851575 -0.11851575]\n",
      "new_w= [ 16.17732696  13.7545206    3.70264779   6.38346859   8.31262497\n",
      "  -0.12976881   1.43775665   0.76344957   7.07436858   4.67547377\n",
      "  -1.7793877    1.4197313    8.89291257   2.8296454   -0.9969729\n",
      "   7.49198118   2.03505627   5.41774696   5.56420729   0.72708447\n",
      "   4.01749686  11.90627926   9.67766647  15.93103087   9.54642868\n",
      "   7.98228318   9.6162315   10.77893468  10.77354873   2.58367618\n",
      "  -0.25820193  -0.31676447  -5.38525726  -2.09474348   6.53682219\n",
      "   4.36466864   3.90587802]\n",
      "NEW_F1= 0.431050229801\n",
      "**Best_f1=0.431123; Speed: 325.034 s / epoch.\n",
      "==================== 47 0.117923167153\n",
      "LAST_F1= 0.431050229801\n",
      "update_w= [ 0.11792317  0.          0.          0.11792317 -0.11792317  0.11792317\n",
      "  0.11792317  0.11792317  0.11792317 -0.11792317  0.11792317  0.11792317\n",
      "  0.11792317  0.11792317  0.11792317 -0.11792317 -0.11792317  0.11792317\n",
      "  0.11792317 -0.11792317  0.11792317 -0.11792317  0.11792317  0.11792317\n",
      "  0.          0.11792317  0.11792317 -0.11792317  0.11792317  0.\n",
      "  0.11792317  0.11792317 -0.11792317 -0.11792317  0.11792317  0.11792317\n",
      "  0.11792317]\n",
      "new_w= [  1.62952501e+01   1.37545206e+01   3.70264779e+00   6.50139175e+00\n",
      "   8.19470180e+00  -1.18456400e-02   1.55567981e+00   8.81372737e-01\n",
      "   7.19229175e+00   4.55755060e+00  -1.66146454e+00   1.53765447e+00\n",
      "   9.01083574e+00   2.94756856e+00  -8.79049731e-01   7.37405801e+00\n",
      "   1.91713310e+00   5.53567013e+00   5.68213046e+00   6.09161299e-01\n",
      "   4.13542003e+00   1.17883561e+01   9.79558963e+00   1.60489540e+01\n",
      "   9.54642868e+00   8.10020635e+00   9.73415467e+00   1.06610115e+01\n",
      "   1.08914719e+01   2.58367618e+00  -1.40278760e-01  -1.98841299e-01\n",
      "  -5.50318043e+00  -2.21266665e+00   6.65474535e+00   4.48259180e+00\n",
      "   4.02380119e+00]\n",
      "NEW_F1= 0.431059734893\n",
      "**Best_f1=0.431123; Speed: 283.19 s / epoch.\n",
      "==================== 48 0.117333551317\n",
      "LAST_F1= 0.431059734893\n",
      "update_w= [ 0.          0.11733355 -0.11733355  0.11733355 -0.11733355 -0.11733355\n",
      "  0.          0.          0.          0.          0.         -0.11733355\n",
      "  0.         -0.11733355  0.         -0.11733355  0.          0.\n",
      " -0.11733355  0.          0.          0.          0.          0.11733355\n",
      "  0.11733355 -0.11733355  0.          0.11733355  0.          0.11733355\n",
      "  0.11733355 -0.11733355 -0.11733355 -0.11733355  0.          0.          0.        ]\n",
      "new_w= [ 16.29525013  13.87185415   3.58531423   6.6187253    8.07736825\n",
      "  -0.12917919   1.55567981   0.88137274   7.19229175   4.5575506\n",
      "  -1.66146454   1.42032092   9.01083574   2.83023501  -0.87904973\n",
      "   7.25672446   1.9171331    5.53567013   5.56479691   0.6091613\n",
      "   4.13542003  11.7883561    9.79558963  16.16628759   9.66376223\n",
      "   7.9828728    9.73415467  10.77834506  10.89147189   2.70100973\n",
      "  -0.02294521  -0.31617485  -5.62051398  -2.3300002    6.65474535\n",
      "   4.4825918    4.02380119]\n",
      "NEW_F1= 0.43105322653\n",
      "**Best_f1=0.431123; Speed: 369.084 s / epoch.\n",
      "==================== 49 0.11674688356\n",
      "LAST_F1= 0.43105322653\n",
      "update_w= [ 0.          0.          0.11674688  0.11674688  0.11674688  0.11674688\n",
      " -0.11674688 -0.11674688  0.          0.11674688  0.11674688 -0.11674688\n",
      "  0.11674688  0.11674688 -0.11674688  0.11674688  0.11674688  0.11674688\n",
      "  0.11674688  0.11674688  0.          0.11674688  0.11674688  0.\n",
      " -0.11674688  0.          0.11674688 -0.11674688  0.11674688  0.\n",
      "  0.11674688  0.          0.11674688  0.11674688  0.11674688  0.          0.        ]\n",
      "new_w= [  1.62952501e+01   1.38718542e+01   3.70206112e+00   6.73547219e+00\n",
      "   8.19411513e+00  -1.24323078e-02   1.43893293e+00   7.64625853e-01\n",
      "   7.19229175e+00   4.67429748e+00  -1.54471765e+00   1.30357403e+00\n",
      "   9.12758262e+00   2.94698190e+00  -9.95796614e-01   7.37347135e+00\n",
      "   2.03387999e+00   5.65241701e+00   5.68154379e+00   7.25908182e-01\n",
      "   4.13542003e+00   1.19051030e+01   9.91233652e+00   1.61662876e+01\n",
      "   9.54701535e+00   7.98287280e+00   9.85090155e+00   1.06615982e+01\n",
      "   1.10082188e+01   2.70100973e+00   9.38016749e-02  -3.16174850e-01\n",
      "  -5.50376710e+00  -2.21325331e+00   6.77149224e+00   4.48259180e+00\n",
      "   4.02380119e+00]\n",
      "NEW_F1= 0.431061525447\n",
      "**Best_f1=0.431123; Speed: 363.207 s / epoch.\n",
      "==================== 50 0.110909539382\n",
      "LAST_F1= 0.431061525447\n",
      "update_w= [ 0.          0.11090954  0.          0.          0.          0.\n",
      "  0.11090954  0.         -0.11090954  0.          0.          0.\n",
      "  0.11090954 -0.11090954  0.          0.          0.          0.          0.\n",
      "  0.          0.          0.          0.          0.          0.          0.\n",
      "  0.          0.          0.          0.          0.         -0.11090954\n",
      " -0.11090954 -0.11090954  0.          0.          0.        ]\n",
      "new_w= [  1.62952501e+01   1.39827637e+01   3.70206112e+00   6.73547219e+00\n",
      "   8.19411513e+00  -1.24323078e-02   1.54984247e+00   7.64625853e-01\n",
      "   7.08138221e+00   4.67429748e+00  -1.54471765e+00   1.30357403e+00\n",
      "   9.23849216e+00   2.83607236e+00  -9.95796614e-01   7.37347135e+00\n",
      "   2.03387999e+00   5.65241701e+00   5.68154379e+00   7.25908182e-01\n",
      "   4.13542003e+00   1.19051030e+01   9.91233652e+00   1.61662876e+01\n",
      "   9.54701535e+00   7.98287280e+00   9.85090155e+00   1.06615982e+01\n",
      "   1.10082188e+01   2.70100973e+00   9.38016749e-02  -4.27084390e-01\n",
      "  -5.61467664e+00  -2.32416285e+00   6.77149224e+00   4.48259180e+00\n",
      "   4.02380119e+00]\n",
      "NEW_F1= 0.43107953737\n",
      "**Best_f1=0.431123; Speed: 425.316 s / epoch.\n",
      "==================== 51 0.105364062413\n",
      "LAST_F1= 0.43107953737\n",
      "update_w= [ 0.10536406  0.          0.10536406  0.10536406  0.10536406  0.10536406\n",
      "  0.10536406 -0.10536406  0.          0.10536406  0.10536406  0.10536406\n",
      "  0.10536406  0.          0.          0.10536406 -0.10536406 -0.10536406\n",
      "  0.10536406  0.10536406  0.          0.10536406 -0.10536406  0.10536406\n",
      "  0.10536406  0.10536406  0.10536406 -0.10536406  0.10536406  0.10536406\n",
      "  0.10536406  0.10536406  0.10536406 -0.10536406  0.          0.10536406\n",
      " -0.10536406]\n",
      "new_w= [ 16.40061419  13.98276369   3.80742518   6.84083625   8.2994792\n",
      "   0.09293175   1.65520653   0.65926179   7.08138221   4.77966155\n",
      "  -1.43935359   1.4089381    9.34385623   2.83607236  -0.99579661\n",
      "   7.47883541   1.92851592   5.54705295   5.78690785   0.83127224\n",
      "   4.13542003  12.01046704   9.80697246  16.27165165   9.65237941\n",
      "   8.08823686   9.95626561  10.55623412  11.11358284   2.80637379\n",
      "   0.19916574  -0.32172033  -5.50931258  -2.42952692   6.77149224\n",
      "   4.58795587   3.91843713]\n",
      "NEW_F1= 0.431017915167\n",
      "**Best_f1=0.431123; Speed: 351.411 s / epoch.\n",
      "==================== 52 0.100095859293\n",
      "LAST_F1= 0.431017915167\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Process PoolWorker-423:\n",
      "Process PoolWorker-421:\n",
      "Process PoolWorker-420:\n",
      "Process PoolWorker-424:\n",
      "Traceback (most recent call last):\n",
      "Traceback (most recent call last):\n",
      "Traceback (most recent call last):\n",
      "Traceback (most recent call last):\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/process.py\", line 258, in _bootstrap\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/process.py\", line 258, in _bootstrap\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/process.py\", line 258, in _bootstrap\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/process.py\", line 258, in _bootstrap\n",
      "    self.run()\n",
      "    self.run()\n",
      "    self.run()\n",
      "    self.run()\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/process.py\", line 114, in run\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/process.py\", line 114, in run\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/process.py\", line 114, in run\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/process.py\", line 114, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/pool.py\", line 102, in worker\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/pool.py\", line 113, in worker\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/pool.py\", line 102, in worker\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/pool.py\", line 102, in worker\n",
      "    task = get()\n",
      "    task = get()\n",
      "    task = get()\n",
      "    result = (True, func(*args, **kwds))\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/queues.py\", line 376, in get\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/queues.py\", line 376, in get\n",
      "    racquire()\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/pool.py\", line 65, in mapstar\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/queues.py\", line 378, in get\n",
      "    racquire()\n",
      "    return map(*args)\n",
      "    return recv()\n",
      "KeyboardInterrupt\n",
      "Process PoolWorker-417:\n",
      "KeyboardInterrupt\n",
      "KeyboardInterrupt\n",
      "Traceback (most recent call last):\n",
      "  File \"<ipython-input-5-9cc56062b81c>\", line 21, in get_update_weight\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/process.py\", line 258, in _bootstrap\n",
      "    self.run()\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/process.py\", line 114, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/pool.py\", line 113, in worker\n",
      "    result = (True, func(*args, **kwds))\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/pool.py\", line 65, in mapstar\n",
      "    return map(*args)\n",
      "  File \"<ipython-input-5-9cc56062b81c>\", line 14, in get_update_weight\n",
      "    predict_labels_list = map(lambda label: label.argsort()[-1:-6:-1], new_score) # 取最大的5个下标\n",
      "    predict_labels_list = map(lambda label: label.argsort()[-1:-6:-1], new_score) # 取最大的5个下标\n",
      "  File \"<ipython-input-5-9cc56062b81c>\", line 14, in <lambda>\n",
      "  File \"<ipython-input-5-9cc56062b81c>\", line 21, in <lambda>\n",
      "    predict_labels_list = map(lambda label: label.argsort()[-1:-6:-1], new_score) # 取最大的5个下标\n",
      "    predict_labels_list = map(lambda label: label.argsort()[-1:-6:-1], new_score) # 取最大的5个下标\n",
      "KeyboardInterrupt\n",
      "KeyboardInterrupt\n",
      "Process PoolWorker-422:\n",
      "Traceback (most recent call last):\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/process.py\", line 258, in _bootstrap\n",
      "    self.run()\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/process.py\", line 114, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/pool.py\", line 113, in worker\n",
      "    result = (True, func(*args, **kwds))\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/pool.py\", line 65, in mapstar\n",
      "    return map(*args)\n",
      "  File \"<ipython-input-5-9cc56062b81c>\", line 13, in get_update_weight\n",
      "    new_score = sum_scores + score*lr\n",
      "KeyboardInterrupt\n",
      "Process PoolWorker-419:\n",
      "Traceback (most recent call last):\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/process.py\", line 258, in _bootstrap\n",
      "    self.run()\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/process.py\", line 114, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/pool.py\", line 113, in worker\n",
      "    result = (True, func(*args, **kwds))\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/pool.py\", line 65, in mapstar\n",
      "    return map(*args)\n",
      "  File \"<ipython-input-5-9cc56062b81c>\", line 12, in get_update_weight\n",
      "    score = np.vstack(np.load(soft_scores_path + score_name))\n",
      "  File \"/home/common/anaconda2/lib/python2.7/site-packages/numpy/lib/npyio.py\", line 419, in load\n",
      "    pickle_kwargs=pickle_kwargs)\n",
      "  File \"/home/common/anaconda2/lib/python2.7/site-packages/numpy/lib/format.py\", line 651, in read_array\n",
      "    array = numpy.fromfile(fp, dtype=dtype, count=count)\n",
      "KeyboardInterrupt\n",
      "Process PoolWorker-418:\n",
      "Traceback (most recent call last):\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/process.py\", line 258, in _bootstrap\n",
      "    self.run()\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/process.py\", line 114, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/pool.py\", line 113, in worker\n",
      "    result = (True, func(*args, **kwds))\n",
      "  File \"/home/common/anaconda2/lib/python2.7/multiprocessing/pool.py\", line 65, in mapstar\n",
      "    return map(*args)\n",
      "  File \"<ipython-input-5-9cc56062b81c>\", line 12, in get_update_weight\n",
      "    score = np.vstack(np.load(soft_scores_path + score_name))\n",
      "  File \"/home/common/anaconda2/lib/python2.7/site-packages/numpy/lib/npyio.py\", line 419, in load\n",
      "    pickle_kwargs=pickle_kwargs)\n",
      "  File \"/home/common/anaconda2/lib/python2.7/site-packages/numpy/lib/format.py\", line 651, in read_array\n",
      "    array = numpy.fromfile(fp, dtype=dtype, count=count)\n",
      "KeyboardInterrupt\n"
     ]
    }
   ],
   "source": [
    "from multiprocessing import  Pool\n",
    "\n",
    "time0 = time.time()\n",
    "last_f1 = f1\n",
    "best_f1 = f1\n",
    "lr = 0.15\n",
    "\n",
    "\n",
    "def get_update_weight(score_name):\n",
    "    \"\"\"根据线下验证集的 f1 值变化趋势来调整模型的融合权重。\n",
    "    Args:\n",
    "        score_name: 需要调整的模型。\n",
    "    Returns:\n",
    "        lr: 模型的权重变化。\n",
    "    \"\"\"\n",
    "    global lr   # 权重调整率\n",
    "    score = np.vstack(np.load(soft_scores_path + score_name))\n",
    "    new_score = sum_scores + score*lr\n",
    "    predict_labels_list = map(lambda label: label.argsort()[-1:-6:-1], new_score) # 取最大的5个下标\n",
    "    predict_label_and_marked_label_list = zip(predict_labels_list, marked_labels_list)\n",
    "    precision, recall, f1 = score_eval(predict_label_and_marked_label_list)\n",
    "    if f1 > last_f1:\n",
    "        return lr\n",
    "    else:\n",
    "        new_score = sum_scores - score*lr\n",
    "        predict_labels_list = map(lambda label: label.argsort()[-1:-6:-1], new_score) # 取最大的5个下标\n",
    "        predict_label_and_marked_label_list = zip(predict_labels_list, marked_labels_list)\n",
    "        precision, recall, f1 = score_eval(predict_label_and_marked_label_list)\n",
    "        if f1 > last_f1:\n",
    "            return -lr\n",
    "    return 0.0\n",
    "    \n",
    "# 更新权重 \n",
    "f1_list = list()\n",
    "w_list = list()\n",
    "decay1 = 0.995\n",
    "decay2 = 0.95\n",
    "decay = decay1\n",
    "for i in xrange(200):\n",
    "    if i == 50:\n",
    "        decay = decay2    # 增加下降速度\n",
    "    lr = lr * decay\n",
    "    p = Pool(8)\n",
    "    weights = np.asarray(weights)\n",
    "    print('=='*10, i, lr)\n",
    "    print('LAST_F1=', last_f1)\n",
    "    update_w = p.map(get_update_weight, scores_names)\n",
    "    update_w = np.asarray(update_w)\n",
    "    p.close()#关闭进程池，不再接受新的进程\n",
    "    p.join()#主进程阻塞等待子进程的退出, 必须要退出以后才能更新里边的全局变量\n",
    "    print('update_w=', update_w)\n",
    "    weights =  weights + update_w              # 更新\n",
    "    print('new_w=', weights)\n",
    "    sum_scores = np.zeros((100000, 1999), dtype=float)\n",
    "    for i in xrange(len(weights)):       # 新的权重组合\n",
    "        scores_name = scores_names[i]\n",
    "        score = np.vstack(np.load(soft_scores_path + scores_name))\n",
    "        score = softmax(score)\n",
    "        sum_scores = sum_scores + score*weights[i]     # 新的 sum_scores\n",
    "    predict_labels_list = map(lambda label: label.argsort()[-1:-6:-1], sum_scores) # 取最大的5个下标\n",
    "    predict_label_and_marked_label_list = zip(predict_labels_list, marked_labels_list)\n",
    "    precision, recall, f1 = score_eval(predict_label_and_marked_label_list)\n",
    "    print('NEW_F1=',f1)\n",
    "    if f1 > best_f1:\n",
    "        best_f1 = f1\n",
    "        np.save('best_weights.npy', weights)\n",
    "    f1_list.append(f1)\n",
    "    w_list.append(weights)\n",
    "    last_f1 = f1 # 更新 f1 \n",
    "    print('**Best_f1=%f; Speed: %g s / epoch.' % (best_f1, time.time() - time0))\n",
    "    time0 = time.time()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [conda root]",
   "language": "python",
   "name": "conda-root-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
